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.