Greetings,
I was playing aroung with JPQL and have found that there is a problem with "is null" queries. When you use "is null" in where clause, query runs correctly, but results are incorrect. Let me show you an example:
- entity
@Entity public class EntityA { @Id Integer id; Integer simpleField; // (getters and setters here) // - populating database for (int x = 1; x < 100; x++) { EntityA a = new EntityA(); a.setId(x); if (Math.random() < 0.5) { a.setSimpleField(new Double(Math.random() * 1000).intValue()); } em.persist(a); } // - selecting records, where simpleField is null Query query = em.createQuery( "SELECT a FROM EntityA a WHERE a.simpleField IS NULL"); List<EntityA> resultList = query.getResultList(); System.out.println("ResultList size = " + resultList.size()); if (resultList.size() == 0) { throw new Exception("There is no EntityA with simpleField == null ???"); } }
ResultList.size() is always 0. It should be somwhere near 50. Is it a bug? Or I missed something?
I have attached full eclipse project with test case for this problem.