BUG #6241: JDBC: blob doesnot work with bytea

Поиск
Список
Период
Сортировка
От Stefan Franke
Тема BUG #6241: JDBC: blob doesnot work with bytea
Дата
Msg-id 201110060826.p968Qpkl005684@wwwmaster.postgresql.org
обсуждение исходный текст
Ответы Re: BUG #6241: JDBC: blob doesnot work with bytea  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-bugs
The following bug has been logged online:

Bug reference:      6241
Logged by:          Stefan Franke
Email address:      stefan@franke.ms
PostgreSQL version: 9.1
Operating system:   any
Description:        JDBC: blob doesnot work with bytea
Details:

To persist a blob you can also use bytea. Unfortunately the JDBC driver does
not support this.

Especially if you can't control the way how the column is accessed, e.g.
using JPA

    @Lob
    @Column(name = "DATA") // using bytea
    private byte[] data;

it fails with distinct JPA implementations (e.g. Hibernate) since the JPA
layer tries to access it as blob.

My workaround is to patch the class org.postgresql.jdbc4.Jdbc4ResultSet:

    public java.sql.Blob getBlob(int i) throws SQLException
    {
        checkResultSet(i);
        if (wasNullFlag)
            return null;

        try {
            return new Jdbc4Blob(connection, getLong(i));
        } catch (PSQLException ex) {
            // bytea use a dummy Blob
            return new SerialBlob(getBytes(i));
        }
    }

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Daniel Cristian Cruz
Дата:
Сообщение: Re: BUG #6226: Broken foreign key stored on database (parent deleted with children still readable, BUG#6225 Update)
Следующее
От: Daniel Cristian Cruz
Дата:
Сообщение: Re: BUG #6226: Broken foreign key stored on database (parent deleted with children still readable, BUG#6225 Update)