-->
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: Detached Criteria Problem
PostPosted: Thu Mar 04, 2010 6:31 pm 
Newbie

Joined: Thu Mar 04, 2010 6:20 pm
Posts: 1
I am having an issue trying to create an Or condition on my Detached Query. Here is what I am trying to do, but so far keep coming up empty handed.

I am trying to use one phone number collected from the UI to be used as an or condition for both the customer and the contact?
Any idea how to use a Detached Query object to obtain these results? Or do I need to change from a detached query to HQL or something else.

Customer Object has a list of phone numbers
Customer object has a contact list
Contacts have a list of phone numbers

DetachedCriteria criteria = DetachedCriteria.forClass(Customer.class);
DetachedCriteria contactCriteria = criteria.createCriteria(OrganizationFieldConstants.CONTACTS);
contactCriteria.createCriteria(ContactFieldConstants.TELEPHONES).add(Restrictions.like(TelephoneFieldConstants.TELEPHONE_NUMBER, contactTelephoneNumber, MatchMode.START));

Now how can I create the Or case for the phone numbers on the Customer Object, hibernate always makes this an and clause.
Please help,
Thanks


Top
 Profile  
 
 Post subject: Re: Detached Criteria Problem
PostPosted: Tue Mar 30, 2010 8:51 pm 
Newbie

Joined: Tue Mar 30, 2010 8:45 pm
Posts: 2
You might wanna use this:
Code:
DetachedCriteria query= ....

query.add(Restrictions.disjunction().add(
            Property.forName("user.username").like(userName,
                  MatchMode.ANYWHERE)).add(
            Property.forName("user.fName").like(userName,
                  MatchMode.ANYWHERE)));



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.