-->
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: And/Or of 2 Criteria/DetachedCriteria
PostPosted: Tue May 13, 2008 2:16 am 
Newbie

Joined: Mon May 12, 2008 1:30 pm
Posts: 1
Location: Poland
Hi All,
How I could add(and/or) one Criteria/DetachedCriteria to another?
(
something like:
ICriteria.And(ICriteria), ICriteria.Or(ICriteria), DetachedCriteria.And(DetachedCriteria), DetachedCriteria.Or(DetachedCriteria)
)

We could easily add one ICriterion to another:
finalCriterion = Expression.And(finalCriterion, localCriterion);
finalCriterion = Expression.Or(finalCriterion, localCriterion);

How I could and/or such Criteria:
finalCriteria.Add(Expression.Ge("Datecreated", value2));
localCriteria.Add(Expression.InsensitiveLike("Name", value1));

Regards


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 13, 2008 5:19 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
You can create a Conjunction/Disjunction as container for your expressions and add them to a final criteria:

Code:
Disjunction or = Expression.Disjunction();
or.Add( Expression... );
or.Add( Expression... );

Conjunction and = Expression.Conjunction();
and.Add( Expression... );
and.Add( Expression... );

criteria.Add(and);
criteria.Add(or);


Is that what you're looking for ?

_________________
--Wolfgang


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.