Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Problem with criteria(isEmpty not working. =/)
Problem with criteria [message #1074540] Fri, 26 July 2013 23:14 Go to next message
jake frog is currently offline jake frog
Messages: 8
Registered: July 2012
Junior Member
Hello,

I am using the criteria below:

CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
CriteriaQuery<Manufacturer> criteriaQuery = criteriaBuilder.createQuery(Manufacturer.class);
criteriaQuery.distinct(true);
Root<Manufacturer> mainRoot = criteriaQuery.from(Manufacturer.class);
Join joinProducts = mainRoot.join("products", JoinType.INNER);
Path<NickName> nickNames = joinProducts.get("nickNames");

Predicate noEmptyList = criteriaBuilder.isEmpty(nickNames.get("justList"));
// or if I use nickNames.get("justList").as(List.class) is the same result

criteriaQuery.where(criteriaBuilder.and(noEmptyList));

TypedQuery<Manufacturer> query = em.createQuery(criteriaQuery);
query.getResultList().size()// check the screen to see the result


but... that is not working. It is bringing me a result with not empty "justList", but in the code I added the predicated "criteriaBuilder.isEmpty".

In the screen it is possible to see a wrong result.
index.php/fa/15729/0/

PS.: The same criteria works with Hibernate and OpenJPA. =/

PS2.: The created query is:
SELECT DISTINCT
    t2.ID, t2.NAME
FROM
    NICKNAME t0,
    MANUFACTURER t2,
    PRODUCT t1
WHERE
    ((SELECT 
            COUNT(t3.ID)
        FROM
            PRODUCT_NICKNAME t6,
            MANUFACTURER_PRODUCT t5,
            NICKNAME_DUMMY_LIST t4,
            DUMMYENTITY t3
        WHERE
            (((t4.id = t0.ID) AND (t3.ID = t4.dummy_id)) AND (((t5.Manufacturer_ID = t2.ID) AND (t1.ID = t5.products_ID)) AND ((t6.Product_ID = t1.ID) AND (t0.ID = t6.nickNames_ID))))) = ?)

[Updated on: Fri, 26 July 2013 23:19]

Report message to a moderator

Re: Problem with criteria [message #1074566 is a reply to message #1074540] Sat, 27 July 2013 01:05 Go to previous messageGo to next message
jake frog is currently offline jake frog
Messages: 8
Registered: July 2012
Junior Member
Just now I noticed that there is a bug opened for this: https://bugs.eclipse.org/bugs/show_bug.cgi?id=386354

And the bug was reported by me. Embarrassed

Sorry, it was so long ago that I could not remember it. -_-''

If you guys could vote for it, I would be happy! Very Happy

[Updated on: Sat, 27 July 2013 01:06]

Report message to a moderator

Re: Problem with criteria [message #1075448 is a reply to message #1074566] Mon, 29 July 2013 08:51 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 995
Registered: July 2009
Senior Member
What EclipseLink versions have you tried this against? Are you been able to run against 2.5 or a 2.6 nightly to verify the SQL is still the same?
icon10.gif  Re: Problem with criteria [message #1075790 is a reply to message #1075448] Tue, 30 July 2013 00:24 Go to previous message
jake frog is currently offline jake frog
Messages: 8
Registered: July 2012
Junior Member
Hello Chris,

Thanks for the response, I tested with version 2.5.0: http://mvnrepository.com/artifact/org.eclipse.persistence/org.eclipse.persistence.jpa/2.5.0 and...

The problem is solved! \o/

Yeeeey! I have to use a version already released to test with my framework (EasyCriteria - http://easycriteria.uaihebert.com).

Thanks for your feedback.

I will update the opened issue.
Previous Topic:Optimization for sequence ID
Next Topic:Sequences in SQL Server 2012 + JPA + Eclipselink
Goto Forum:
  


Current Time: Wed Apr 16 21:01:43 EDT 2014

Powered by FUDForum. Page generated in 0.01573 seconds