我最近将我的hibernate项目从版本3迁移到4.我相信'SerializableBlob'类在Hibernate 4中已被弃用.Hibernate中'SerializableBlob'的等价类是什么4.Im在我的工作区中出错。下面的示例代码段。请建议我解决方案。提前致谢
Query query = session.createSQLQuery(sql.toString().replaceAll("PROCESS_NAME"," wfactivity.PROCESS_NAME"))
.setFirstResult(firstResult)
.setMaxResults(maxResult+1);
List blobList = query.list();
try {
for (Object arr : blobList) {
SerializableBlob blob = null;
if (arr.getClass().isArray()) {
blob = (SerializableBlob) Array.get(arr, 0);
} else {
blob = (SerializableBlob) arr;
}
WfActivity wfActivity = new WfActivity();
int bytes = (int) blob.length();
wfActivity.setDataStructure(blob.getBytes(1L, bytes));
resultList.add(wfActivity);
}
} catch (SQLException exp) {
logger.info("Error occured while converting Blob object to java byte[].........."+exp.getMessage());
}
答案 0 :(得分:0)
在新的Hibernate中,有一个名为org.hibernate.type.SerializableToBlob类型的参数化类型。
看看这个答案: How to express a Serializable Blob type in a hibernate mapping file