Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Two BLOBs (OID) in table?

4 views
Skip to first unread message

Stanislav Mironov

unread,
Apr 13, 2008, 9:29:53 AM4/13/08
to
Hello All!

I created entity with 2 BLOB columns in one table: one for image and one
for thumbnail. Storing image and getting it back in another session
works pretty good.

But when I set thumbnail BLOB successfully, the original BLOB becomes
empty. Retrieved entity returns length 0 for image BLOB.

@Lob private Blob image;
@Lob private Blob thumbnail;

Hibernate 3.2.6, Annotations 3.3.0, PostgreSQL 8.3.1, JDBC 8.3-603.
The problem is 100% reproducible. Please, help?

--
Stanislav Mironov

--
Sent via pgsql-jdbc mailing list (pgsql...@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

Kris Jurka

unread,
Apr 13, 2008, 9:50:03 AM4/13/08
to

On Sun, 13 Apr 2008, Stanislav Mironov wrote:

> I created entity with 2 BLOB columns in one table: one for image and one for
> thumbnail. Storing image and getting it back in another session works pretty
> good.
>
> But when I set thumbnail BLOB successfully, the original BLOB becomes empty.
> Retrieved entity returns length 0 for image BLOB.
>
> @Lob private Blob image;
> @Lob private Blob thumbnail;
>
> Hibernate 3.2.6, Annotations 3.3.0, PostgreSQL 8.3.1, JDBC 8.3-603.
> The problem is 100% reproducible. Please, help?
>

It's not clear what JDBC calls this actually involves, so it's difficult
to tell where things are going wrong. If you can create a test case that
shows the failure using the postgresql JDBC driver alone, I'd be happy to
look at it.

Kris Jurka

Stanislav Mironov

unread,
Apr 14, 2008, 5:18:51 AM4/14/08
to
Kris Jurka wrote:
> On Sun, 13 Apr 2008, Stanislav Mironov wrote:
>> I created entity with 2 BLOB columns in one table: one for image and
>> one for thumbnail. Storing image and getting it back in another
>> session works pretty good.
>>
>> But when I set thumbnail BLOB successfully, the original BLOB becomes
>> empty. Retrieved entity returns length 0 for image BLOB.
>>
>> @Lob private Blob image;
>> @Lob private Blob thumbnail;
>>
>> Hibernate 3.2.6, Annotations 3.3.0, PostgreSQL 8.3.1, JDBC 8.3-603.
>> The problem is 100% reproducible. Please, help?
>>
>
> It's not clear what JDBC calls this actually involves, so it's
> difficult to tell where things are going wrong. If you can create a
> test case that shows the failure using the postgresql JDBC driver
> alone, I'd be happy to look at it.

Sorry, I cannot emulate Hibernate (it's too complicated), but I've
created hibernate test that reproduces this bug.
After some experiments it seems like I've figured out bug sequence: it
happens because I create thumbnail BLOB with data from image BLOB.

1. getBinaryStream or getBytes on first BLOB before setting second BLOB
causes first BLOB truncation to zero.

2. Any access (even length()) to first BLOB after setting second BLOB
with setBlob and executeUpdate causes this bug:
SEVERE: ERROR: invalid large-object descriptor: 0
org.postgresql.util.PSQLException: ERROR: invalid large-object descriptor: 0
at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1548)
at
org.postgresql.core.v3.QueryExecutorImpl.receiveFastpathResult(QueryExecutorImpl.java:586)
at
org.postgresql.core.v3.QueryExecutorImpl.fastpathCall(QueryExecutorImpl.java:485)
at org.postgresql.fastpath.Fastpath.fastpath(Fastpath.java:74)
at org.postgresql.fastpath.Fastpath.fastpath(Fastpath.java:114)
at org.postgresql.fastpath.Fastpath.getInteger(Fastpath.java:126)
at org.postgresql.largeobject.LargeObject.tell(LargeObject.java:264)
at org.postgresql.largeobject.LargeObject.size(LargeObject.java:279)
at
org.postgresql.jdbc2.AbstractJdbc2BlobClob.length(AbstractJdbc2BlobClob.java:44)
at org.hibernate.lob.SerializableBlob.length(SerializableBlob.java:31)
at
ru.smilabs.mir.centre.db.PostgreSQLTest$3.run(PostgreSQLTest.java:142)

When I replace first BLOB access with fake generated data - everything
works perfectly as it should. Both BLOBs are stored and retrieved right.
Also original code worked fine with Apache Derby, H2 and MySQL so this
makes me think the trouble is on PostgreSQL JDBC side.

I'm ready to provide more data on demand.
Thanks in advance!

--
Stanislav Mironov

Kris Jurka

unread,
Apr 14, 2008, 11:47:15 AM4/14/08
to

On Mon, 14 Apr 2008, Stanislav Mironov wrote:

> Sorry, I cannot emulate Hibernate (it's too complicated), but I've created
> hibernate test that reproduces this bug.

Could you send us that test code?

Kris Jurka

Kris Jurka

unread,
May 19, 2008, 11:12:59 PM5/19/08
to

On Mon, 14 Apr 2008, Kris Jurka wrote:

> On Mon, 14 Apr 2008, Stanislav Mironov wrote:
>
>> Sorry, I cannot emulate Hibernate (it's too complicated), but I've created
>> hibernate test that reproduces this bug.
>
> Could you send us that test code?
>

Do you still have this test? Can you send it?

0 new messages