我在我以前从未见过的日志中发现了这个异常,我正在使用Hibernate 4.1.7
这是否表示我的数据库已损坏,或者这是Hibernate中的错误。我在http://lists.jboss.org/pipermail/hibernate-issues/2010-November/026487.html找到了对此错误的引用,但这引用了更早版本的hibernate并且已针对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
答案 0 :(得分:3)
让我们从Hibernate的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.
例如:
@Lob
public String getFullText() {
return fullText;
}
@Lob
public byte[] getFullCode() {
return fullCode;
}
知道这一点,可能意味着该对象不在数据库中。也许它已从表中删除但在引用的表中没有删除。让我们从表Blobs
中说,删除了带有id
5的blob,但是在表users_blobs
中,它被引用为:
| user_id | blob_id|
| 4 | 5 | //This entry blob were delete but is still referenced by that table
| 5 | 2 |
如果是这种情况,您应该重新定义users_blobs
(例如)约束,以便在删除blob时将其删除或放置null
。
此外,此链接也很有用:
答案 1 :(得分:1)
这肯定是数据库的问题,而不是hibernate。您必须查看异常的 cause ,这是h2
数据库代码中抛出的异常。
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)
在互联网上搜索“h2数据库丢失的高管条目”表明这是一个h2
特定的错误消息,答案如下:
https://groups.google.com/forum/#!topic/h2-database/xey-czIhocM
表明数据库很可能已损坏。
如果这种情况经常发生,那么关于这种情况发生的更多研究将是合适的。但这在数据库开发人员处于活动状态的h2
组中最好。
答案 2 :(得分:1)
似乎您正在尝试加载已经删除的数据寄存器,尝试同步对该休眠DAO的访问。多线程应用程序应该为每个线程使用一个连接。