Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] CriteriaBuilder and() isNotNull() equals() problem (BUG 316144)

I re-ran the test and your code and it works in the latest 2.2 build.

Ensure that you are using the correct jar, and try downloading the latest
2.2 or 2.3 nightly build.



MarcNuri wrote:
> 
> <p>Hello</p>
> <p>Recently I've started using the JPA 2.0 Criteria API. In my first
> approach I'm already having problems because the API doesn't behave as
> expected.</p>
> <p>My code looks as follows:
> <pre>
>         final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
>         final CriteriaQuery<Long> cQuery = cb.createQuery(Long.class);
>         final Root<ExpedicionD3> root = cQuery.from(ExpedicionD3.class);
>         final Path<Long> codigoHojaRuta =
> root.get(ExpedicionD3_.codigoHojaRuta);
>         cQuery.select(cb.max(codigoHojaRuta));
>         cQuery.where(cb.and(
>                 //BUG IN ECLIPSELINK
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=316144
>                 cb.isNotNull(root.get(ExpedicionD3_.diccionario)),
>                 cb.equal(root.get(ExpedicionD3_.corresponsalOrigen),
> origen),
>                 cb.equal(root.get(ExpedicionD3_.corresponsalDestino),
> destino)));
>         final TypedQuery<Long> typedQuery =
> entityManager.createQuery(cQuery);
>         return typedQuery.getSingleResult();
> </pre></p>
> <p>The above TypedQuery resolves to the following SQL: <pre>SELECT
> MAX(codigohojaruta) FROM expediciond3 WHERE ((corresponsalorigen = ?) AND
> (corresponsaldestino = ?))</pre>So the isNotNull clause is not taken into
> account.</p>
> <p>When searching for what was happening I came across the following BUG 
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=316144 316144 , luckily the
> bug appears to be fixed.</p>
> <p>The problem is that when I downloaded eclipselink 2.2.0 RC3 yesterday
> to test if I could run my code without problems, the TypedQuery still
> resolved to an SQL query where the isnotnull clause was omitted.</p>
> <p>Is there something wrong in my code or is the BUG still open?</p>
> <p>Regards</p>
> --
> Marc Nuri
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
Blog:  http://java-persistence-performance.blogspot.com/ Java Persistence
Performance 
-- 
View this message in context: http://old.nabble.com/CriteriaBuilder-and%28%29-isNotNull%28%29-equals%28%29-problem-%28BUG-316144%29-tp30824036p30827878.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top