Community
Participate
Working Groups
Build Identifier: 2.3.0 CriteriaBuilder.and() method gives wrong results for certain parameters. ---------------------------------------------------- Code snippet: CriteriaBuilder cb = this.em.getCriteriaBuilder(); CriteriaQuery<MyEntity> query = cb.createQuery(MyEntity.class); query.where(cb.and(cb.and(), cb.or())); TypedQuery<MyEntity> typedQuery = this.em.createQuery(query); typedQuery.getResultList(); ---------------------------------------------------- Generated SQL: SELECT ID FROM MYENTITY ---------------------------------------------------- The SQL shows that the where clause has been evaluated as 'true', which is wrong. However, when order of parameters is changed, it starts to work as expected. I.e. query.where(cb.and(cb.or(), cb.and())) results in a correct SQL query containing "WHERE 1=0". The same applies when disjunction() is used instead of or(). Reproducible: Always
Tested with the same result on version Eclipse Persistence Services - 2.3.2.v20111125-r10461
Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines Community: Please vote for this bug if it is important to you. Votes are one of the main criteria we use to determine which bugs to fix next.
This got fixed in 2.5.1 You can have an example running test case: https://github.com/kretes/eclipseLinkPlayground/blob/master/src/test/java/some/NotAndPredicateTest.java when using eclipselink 2.5.1 it worked. with previous - not.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink