休眠-查询为实体中的所有字段返回 null

Long fooId = 39;
Query query = getCurrentSession().createQuery("from FooEntity where deleted IS FALSE AND id=:fooId" );
query.setParameter( "fooId", fooId );
FooEntity fooEntity = ( FooEntity ) query.uniqueResult();

检查FooEntity会显示以下结果
(id=null, name=null, deleted=null)

虽然同一查询从数据库返回完美结果
select * from foo where deleted IS FALSE AND id=39
(id, name, deleted) => (39, 'Bar', false)

It has to be noted that this occurs in random cases only. Most of the time hibernate returns perfect result.

最佳答案

请尝试在下一行中对值进行logsysout

对于我和OP来说,问题是相同的,只是Java Debugger没有显示该值。价值一直存在。

10-04 13:58