"Session closed" error when trying to get blob from DB using getBinaryStream ()

I am using Hibernate 3.1 and Oracle 10 DB. Blob is defined as @Lob @Basic @Column in the Hibernate object that corresponds to the corresponding DB table. Error -java.sql.SQLException: Closed connection - seems to appear once in a while, not every attempt to get a blob from the DB. It looks like a hibernation load issue, so I thought about specifying the fetch type to use - EAGER seems to be correct in this case, but coudln't find a way to specify fetch type for @Column object type (is there a way to do this is for collections / "one to many" etc.)

Thank you for your help, thanks.

+1


source to share


4 answers


I recently implemented a hibernate system on top of Oracle 11g db that uses blobs. There is no real magic.

A common reason for hibernation to "hibernate" is (not to point out the obvious) that the session to which your entity is attached is indeed closed.

Determine where and when the session opens and closes. It might not be entirely obvious if you are using AOP or spring to manage this for you.



Also, I'm pretty sure you want an open transaction, or at least a db connection with auto-write disabled.

Gareth

0


source


Is it against Oracle database?

I had to resort to custom datatypes in Hibernate to get this to work, but that was using Hibernate 3.0 against Oracle 9 db.



See http://www.hibernate.org/56.html for a long discussion on this (including custom data types).

+1


source


If you want to specify a sampling strategy, use:

@Basic(fetch = FetchType.LAZY)

      

for your member.

0


source


Setting the system property hibernate.jdbc.use_streams_for_binary = true might help.

0


source







All Articles