Hi,
here's the code:
Code:
Session session = HibernateUtil.openSession();
session.beginTransaction();
BlastQuery q = (BlastQuery) session.load(BlastQuery.class, new Long(8));
session.getTransaction().commit();
session.beginTransaction();
session.update(q);
try {
Blob file = q.getInputAlignmentFile();
System.out.println(file.getBytes(1, (int) file.length()));
} catch (SQLException e) {
e.printStackTrace();
}
session.getTransaction().commit();
session.close();
And the exception:Code:
org.postgresql.util.PSQLException: ERROR: invalid large-object descriptor: 0
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1512)
at org.postgresql.core.v3.QueryExecutorImpl.receiveFastpathResult(QueryExecutorImpl.java:583)
at org.postgresql.core.v3.QueryExecutorImpl.fastpathCall(QueryExecutorImpl.java:482)
at org.postgresql.fastpath.Fastpath.fastpath(Fastpath.java:70)
at org.postgresql.fastpath.Fastpath.fastpath(Fastpath.java:110)
at org.postgresql.fastpath.Fastpath.getInteger(Fastpath.java:122)
at org.postgresql.largeobject.LargeObject.tell(LargeObject.java:255)
at org.postgresql.largeobject.LargeObject.size(LargeObject.java:270)
at org.postgresql.jdbc2.AbstractJdbc2BlobClob.length(AbstractJdbc2BlobClob.java:44)
at org.hibernate.lob.SerializableBlob.length(SerializableBlob.java:31)
at biojazz.web.NewSequence.main(NewSequence.java:219)
Everything is fine, when I read the blob in the same transaction with object loading. But I can not do this in a real situation.
Any advices?
Thanks in advance.
Hibernate version: 3
Name and version of the database you are using: PostgreSQL 8.1