-->
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: one searchfield, several fields on the model
PostPosted: Wed Jul 09, 2008 3:41 am 
Newbie

Joined: Wed Jan 30, 2008 9:51 am
Posts: 1
Hello people, I can't seem to figure this one out;

I have one search field; Name. It's supposed to search on
-firstName
-middleName
-surName

I'd like to find an entity if the value is in any of these fields.

Example;

Marylin Monroe is registered as
-firstName : Marolyn
-middleName : (nothing)
-surName : Monro

I'd like to find this entity when the search field's value is;
"Mar" - firstName restriction
"Mar Mon" - firstName and surName restriction
"Mon" - surName restriction
"ar ro" - firstName and surName restriction anywhere
"ro" - surName restriction anywhere.

How do I combine them?

First I tried something like this on the two first fields; I know now that this wont work;

Code:
  customerCriteria.add(
                    Restrictions.or(
                        Restrictions.and(
                            Restrictions.ilike("firstName", getName(), MatchMode.ANYWHERE),
                            Restrictions.ilike("surName", getName(), MatchMode.ANYWHERE)),
                        Restrictions.or(
                            Restrictions.ilike("firstName", getName(), MatchMode.ANYWHERE),
                            Restrictions.ilike("surName", getName(), MatchMode.ANYWHERE))));


Top
 Profile  
 
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.