-->
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.  [ 1 post ] 
Author Message
 Post subject: potential solution
PostPosted: Thu Dec 29, 2005 1:24 pm 
this where-clause cannot be done directly with Criteria API:


where collectionA is empty
or collectionA.typeId != 1
or collectionA.typeId != 2
or collectionA.typeId != 3

However with a bit of lateral thinking from my brainy colleague Bob Boothby (who's not on this list unfortunately - but you can find his blog here: http://bbboblog.blogspot.com/ if I'm allowed to do that) I implemented the where-clause differently:

where not exists(select id from collectionA where typeId != .....etc)

using a detached criteria on a subquery so:

Code:
        DetachedCriteria detachedCriteria = DetachedCriteria
                .forClass(RetentionActivity.class, "previouslyAccessed");
        detachedCriteria.setProjection(Property.forName("id"));
        Disjunction disjunction = Expression.disjunction();
        disjunction.add(Property.forName("retentionActivityType.id").eq(
            RetentionActivityType.RENOTIFICATION_DONE.getId()));
        detachedCriteria.add(disjunction);
        detachedCriteria.add(Property
                .forName("reportSchedule.id")
                .eqProperty(criteria.getAlias() + ".id"));
        criteria.add(Subqueries.notExists(detachedCriteria));



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

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.