From: Stefan Franke <stefan@franke.ms>
To: pgsql-bugs@postgresql.org
Subject: BUG #6241: JDBC: blob doesnot work with bytea
Date: Thu, 6 Oct 2011 08:26:51 GMT
Message-ID: <201110060826.p968Qpkl005684@wwwmaster.postgresql.org> (raw)
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));
}
}
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: stefan@franke.ms
Subject: Re: BUG #6241: JDBC: blob doesnot work with bytea
In-Reply-To: <201110060826.p968Qpkl005684@wwwmaster.postgresql.org>
References: <201110060826.p968Qpkl005684@wwwmaster.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox