-->
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: "OR"-connection with ICriteria + Expression
PostPosted: Fri Jan 04, 2008 9:45 am 
Newbie

Joined: Tue Oct 30, 2007 10:53 am
Posts: 8
Location: Luxemburg
Hi!

I've got a question about the correct use of ICriteria and Expression. I've got a simple example, loading a TMaterial-object where the corresponing Objects have the values "TestHouse" and "TestName" and "TestTitel".

Code:
ICriteria crit1 = session.CreateCriteria(TMaterial);
ICriteria crit2 = crit1.CreateCriteria("LocationId");
ICriteria crit3 = crit1.CreateCriteria("TMaterialContractorList");
ICriteria crit4 = crit1.CreateCriteria("ProgramId");
crit2.Add(Expression.Eq("LocationName", "TestHouse"));
crit3.Add(Expression.Eq("ContractorName", "TestName"));
crit4.Add(Expression.Eq("TitleOriginal", "TestTitel"));
object results = crit1.List();


But what I would like to get is all the Objects with the value of "TestHouse" AND ("TestName" OR "TestTitel") ...

Is there a way to get these results?

Thanks a lot for youtr help...!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 04, 2008 9:53 am 
Newbie

Joined: Tue Oct 30, 2007 10:53 am
Posts: 8
Location: Luxemburg
I did some real bad mistake, sorry for this stupid question...

Using something like

Quote:
crit4.Add(Expression.Or(Expression.Eq("Director1", "director1"),Expression.Eq("Director2", "director1")));


did the job perfectly...


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.