Hibernate - 查询对实体中的所有字段返回 null,而同一查询从数据库完美返回

Vis*_*G S 5 java postgresql hibernate spring-mvc

Hibernate - 查询对实体中的所有字段返回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();
Run Code Online (Sandbox Code Playgroud)

检查 FooEntity,显示以下结果

(id=null, name=null, deleted=null)
Run Code Online (Sandbox Code Playgroud)

虽然相同的查询从数据库返回完美的结果

select * from foo where deleted IS FALSE AND id=39
(id, name, deleted) => (39, 'Bar', false)
Run Code Online (Sandbox Code Playgroud)

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

Aru*_*rty 3

请尝试logsysout下一行中的值。

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