Skip to main content


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] Sat, 27 July 2013 03:14 Go to next message
jake frog is currently offline jake frogFriend
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: Sat, 27 July 2013 03:19]

Report message to a moderator

Re: Problem with criteria [message #1074566 is a reply to message #1074540] Sat, 27 July 2013 05:05 Go to previous messageGo to next message
jake frog is currently offline jake frogFriend
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 05:06]

Report message to a moderator

Re: Problem with criteria [message #1075448 is a reply to message #1074566] Mon, 29 July 2013 12:51 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
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 04:24 Go to previous message
jake frog is currently offline jake frogFriend
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: Thu Mar 28 13:41:16 GMT 2024

Powered by FUDForum. Page generated in 0.06083 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top