-->
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.  [ 3 posts ] 
Author Message
 Post subject: Query for two entities fields
PostPosted: Tue Nov 29, 2011 2:46 pm 
Newbie

Joined: Sat Feb 12, 2011 3:49 pm
Posts: 13
Hi there.

I know that I can search into two entities with:

Code:
createFullTextQuery(luceneQuery, User.class, Role.class)


Let's say the User has a couple of properties "name" and "description" and Role also has "name" and "active". I don't know if is possible to query for an specific entity field. I mean, something like:

Code:
User.name:pepe OR Role.name:juan


Thanks in advance.


Top
 Profile  
 
 Post subject: Re: Query for two entities fields
PostPosted: Wed Nov 30, 2011 6:19 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

no you cannot. The classname is not part of the field name. You can just generally search for the field name. If it happens to be a field on both classes you get the desired OR result. If only one class had the name field, say User you will only get instances of these type. If the field names differ, just build a BooleanQuery.

--Hardy


Top
 Profile  
 
 Post subject: Re: Query for two entities fields
PostPosted: Wed Nov 30, 2011 6:39 am 
Newbie

Joined: Sat Feb 12, 2011 3:49 pm
Posts: 13
Ok, thanks for the confirmation because I was not sure. I think I can get the same result creating an specific indexed entity with fields of both classes. This should work AFAIK.


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