JPA 2 Criteria API: why is isNull being ignored when in conjunction with equal?

时间秒杀一切 提交于 2019-12-06 06:13:10

I tested your code and criteria query with EclipseLink (you're using EclipseLink, right?) and I reproduced the behavior: the isNull part is just ignored.

However, with Hibernate Entity Manager 3.5.1, the following query is generated:

select ambulanced0_.id as id7_, ambulanced0_.ambulance_id as ambulance5_7_, ambulanced0_.beginDate as beginDate7_, ambulanced0_.endDate as endDate7_, ambulanced0_.reason as reason7_ 
from AmbulanceDeactivation ambulanced0_ 
where (ambulanced0_.endDate is null) and ambulanced0_.ambulance_id=?

Which is the expected result. So I guess that we can assume this to be a bug of your JPA 2.0 provider.

I had the same strange behavior using Glassfish 3.0.1 which has embedded EclipseLink 2.0.

I have tried to change the embedded eclipselink libraries with the Glassfish 3.1.2 contained Eclipselink 2.3 library carefully. It solved the problem. So it is absolutely sure that the isNull check in equal condition is an eclipselink bug using criteriaBuilder.

I will upgrade soon our GlassFish environment in order to eliminate the problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!