-->
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.  [ 5 posts ] 
Author Message
 Post subject: Properties to search
PostPosted: Sun May 18, 2008 2:25 am 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
Hi,

I have two entitites ClassA and ClassB. The following shows how they look like

Code:

class A {

  String name;

  Set<B> collectionOfBs = new HashSet<B>();

}



Code:
class B {
    String desc;
   
    Class A a;
}



Now when I set up my search code and pass the properties is the following acceptable:

Code:
new String[]{"name", "desc"};


or does it need to be:
Code:
new String[]{"name","collectionOfBs.desc"}


I have tried both and I am able to search using both ...but I'm not sure what the practice should be...any help would be appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 18, 2008 2:56 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Are both classes A and B marked as @Indexed?
Do you specify which type of entities you are searching?

Quote:
Now when I set up my search code and pass the properties is the following acceptable

What does the code look like? I don't understand what you are going to do with that array.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 18, 2008 7:10 am 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
Hi
Both classes A and B are annotated with @Indexed. I plan to use the array to do the following:

Code:
MultiFieldQueryParser parser = new MultiFieldQueryParser(new String[]{"name","collectionOfBs.desc"},
  new StandardAnalyzer());
Query query = parser.parse( "xyz" );


For argument sakes lets presume I will be passing A as an entity to searched on. Hope that is enough info.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 18, 2008 6:41 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
in theory when searching "B" entities the property should be in the index named as "desc",
for "A" objects the linked property should be written as "collectionOfBs.desc".

In practice I didn't test it, also you may override this naming scheme using annotations.
I would suggest you to look in your index using luke, it may clarify the index structure:
http://hibernate.org/446.html

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 19, 2008 3:23 am 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
Hi,

Thanks for your reply. In that case if I was doing the following:

Code:
org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery( query, A.class , B.class);


then I would need to specify the following properties:
Code:
new String[]{"collectionOfBs.desc", "desc"}


"desc" being a property on class B.


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