-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Problem with negation of CompoundPredicate (JPA Criteria)
PostPosted: Wed Dec 29, 2010 4:15 am 
Newbie

Joined: Wed Dec 29, 2010 3:58 am
Posts: 4
Hi All,

I'm creating query with JPA Criteria API:
Code:
        CriteriaBuilder cb = em.getCriteriaBuilder();
        CriteriaQuery cq = cb.createQuery();
        Root cr = cq.from(City.class);
        cq.select(cr);
        Predicate p = cb.or(cb.like(cr.get("cityInfo"), "%1%"), cb.isNull(cr.get("cityInfo")));
        p = p.not(); // THIS LINE has no effect
        cq.where(p);
        Query q= em.createQuery(cq);
        List<City> cities = q.getResultList();

Generated query is (does not matter with or without negation):
Code:
    select
        city0_.cityId as cityId0_,
        city0_.cityInfo as cityInfo0_,
        city0_.cityName as cityName0_,
        city0_.countryId as countryId0_
    from
        City city0_
    where
        city0_.cityInfo like ?
        or city0_.cityInfo is null


I've found out that created predicate is instance of org.hibernate.ejb.criteria.predicate.CompoundPredicate.
Method render() takes into account isNegated() only when there is no expressions.
isNegated() is not checked if expressions exist.
I've checked JSR317 and haven't found any exceptions regarding negation and compound predicates.

Should I register bug in JIRA or am I missing something?

Best regards,
Alius.


Top
 Profile  
 
 Post subject: Re: Problem with negation of CompoundPredicate (JPA Criteria)
PostPosted: Tue Jan 25, 2011 10:10 pm 
Newbie

Joined: Wed Dec 29, 2010 3:58 am
Posts: 4
Anyone else has this problem?

Anyone uses Hibernate for JPA Criteria API ?


Top
 Profile  
 
 Post subject: Re: Problem with negation of CompoundPredicate (JPA Criteria)
PostPosted: Mon Jan 31, 2011 10:24 am 
Newbie

Joined: Wed Dec 29, 2010 3:58 am
Posts: 4
Created issue in JIRA:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5884


Top
 Profile  
 
 Post subject: Re: Problem with negation of CompoundPredicate (JPA Criteria)
PostPosted: Wed Feb 09, 2011 9:04 am 
Newbie

Joined: Wed Dec 29, 2010 3:58 am
Posts: 4
Issue resolved in 3.6.1


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.