I found this exception in my logs I have never seen it before, Im using Hibernate 4.1.7
Does this indicate that my database is corrupted , or this a bug in Hibernate. I found a reference to this error at http://lists.jboss.org/pipermail/hibernate-issues/2010-November/026487.html but this referred to a much earlier version of hibernate and was fixed for Hibernate 4.0
org.hiorg.hibernate.HibernateException: IOException occurred reading a binary value
at org.hibernate.type.descriptor.java.DataHelper.extractBytes(DataHelper.java:187)
at org.hibernate.type.descriptor.java.PrimitiveByteArrayTypeDescriptor.wrap(PrimitiveByteArrayTypeDescriptor.java:124)
at org.hibernate.type.descriptor.java.PrimitiveByteArrayTypeDescriptor.wrap(PrimitiveByteArrayTypeDescriptor.java:41)
at org.hibernate.type.descriptor.sql.BlobTypeDescriptor$5.doExtract(BlobTypeDescriptor.java:118)
at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:65)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:269)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:265)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:238)
at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:357)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2807)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1545)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1477)
at org.hibernate.loader.Loader.getRow(Loader.java:1377)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:644)
at org.hibernate.loader.Loader.doQuery(Loader.java:854)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:293)
at org.hibernate.loader.Loader.doList(Loader.java:2382)
at org.hibernate.loader.Loader.doList(Loader.java:2368)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2198)
at org.hibernate.loader.Loader.list(Loader.java:2193)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:122)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1618)
at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:374)
at com.jthink.songkong.db.SongCache.loadSongsFromDatabase(SongCache.java:57)
at com.jthink.songkong.analyse.analyser.SongGroup.getSongs(SongGroup.java:48)
at com.jthink.songkong.analyse.analyser.DiscogsSongGroupMatcher.call(DiscogsSongGroupMatcher.java:63)
at com.jthink.songkong.analyse.analyser.DiscogsSongGroupMatcher.call(DiscogsSongGroupMatcher.java:28)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.io.IOException: org.h2.jdbc.JdbcSQLException: IO Exception: "Missing lob entry: 5587/4" [90028-172]
at org.h2.message.DbException.convertToIOException(DbException.java:348)
at org.h2.store.LobStorageBackend$LobInputStream.fillBuffer(LobStorageBackend.java:695)
at org.h2.store.LobStorageBackend$LobInputStream.readFully(LobStorageBackend.java:668)
at org.h2.store.LobStorageBackend$LobInputStream.read(LobStorageBackend.java:654)
at org.hibernate.type.descriptor.java.DataHelper.extractBytes(DataHelper.java:179)
... 31 more
Caused by: org.h2.jdbc.JdbcSQLException: IO Exception: "Missing lob entry: 5587/4" [90028-172]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:169)
at org.h2.message.DbException.get(DbException.java:146)
at org.h2.store.LobStorageBackend.readBlock(LobStorageBackend.java:203)
at org.h2.store.LobStorageBackend$LobInputStream.fillBuffer(LobStorageBackend.java:692)
... 34 more
Let's start from the Hibernate's doc:
@Lob indicates that the property should be persisted in a Blob or a Clob depending on the property type: java.sql.Clob, Character[], char[] and java.lang.String will be persisted in a Clob. java.sql.Blob, Byte[], byte[] and serializable type will be persisted in a Blob.
For example:
Knowing this, it could mean that the object is not in the database. Maybe it was deleted from the table but in a referenced table didn't. Let's say that from the table
Blobs
, the blob withid
5 were deleted, but in the tableusers_blobs
it is stille referenced like:If that's the case, you should redefine your
users_blobs
(for example) constraints so it will be deleted or putnull
if blob is deleted.Also, this link could be useful too:
http://h2-database.66688.n3.nabble.com/IO-Exception-quot-Missing-lob-entry-1-0-quot-90028-171-when-trying-to-read-a-BLOB-longer-than-128-bye-td4026236.html