-->
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.  [ 2 posts ] 
Author Message
 Post subject: DetachedCriteria or/and
PostPosted: Wed Jul 05, 2006 11:44 am 
Beginner
Beginner

Joined: Sat Mar 13, 2004 4:00 pm
Posts: 32
Is there an example of how to use "or" conditions using DetachedCriteria? I've tried Restriction.or and Restriction.disjunction() and it doesn't accept DetachedCriteria as a parameter.

Thanks,

Rich


Top
 Profile  
 
 Post subject: It's possible to create DetachedCriteria with OR or AND
PostPosted: Tue Aug 01, 2006 12:46 pm 
Newbie

Joined: Mon Jul 31, 2006 5:18 am
Posts: 2
You can do this like in the following code I did.
There are Restrictions in Restrictions.
If you want to distinct the result add the last statement.

// ** begin

criteria = session.createCriteria().add(
Restrictions.or(
// startpoint in value
(Restrictions.and(Restrictions.ge(startpoint, recort.getStart() ), (Restrictions.le(startpoint, record.getStop() ) ))),
//endpoint in value
(Restrictions.and(Restrictions.gt(endpoint, record.getStart() ),
(Restrictions.lt(endpoint, record.getEnd()) )))
)
);

criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);

// ** end

I hope I could help you.

Kind regards
Martin


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.