-->
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.  [ 7 posts ] 
Author Message
 Post subject: Unable to project "_hibernate_class" field?
PostPosted: Thu Oct 30, 2008 10:20 am 
Beginner
Beginner

Joined: Fri Sep 26, 2008 2:39 am
Posts: 20
Hi everybody

I have the following problem. I'm doing a FullTextQuery and would like to use Projection instead of retrieving the objects from the Database.

I stored a key Value in the lucene index. - which is retrieved by my projection. - But i also need to know the "_hibernate_class" field value, but the projection does not return it (checking with luke it clearly is stored in the index)

I tried:

fullTextQuery.setProjection("keyobject",DocumentBuilder.CLASS_FIELDNAME)

and also

fullTextQuery.setProjection("keyobject", "_hibernate_class")

both leave me hanging with no value returned for [1] and the correct keyobject for [0].

Is hibernate-search hiding this field from me? - and if so, is there a way to retrieve it anyway?

Thanks for reading,

greetings
JP


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 30, 2008 10:38 am 
Beginner
Beginner

Joined: Fri Sep 26, 2008 2:39 am
Posts: 20
Update - I found a (simple) way to access the filed anyway:

fullTextQuery.setProjection("keyobject", FullTextQuery.DOCUMENT)

And in the resulting projection array i can access the filed of the lucene document and get my classname:

Document doc = (Document)objects[1];
String classname = doc.getField("_hibernate_class").stringValue();


But I am not sure how much overhead this is creating - and i am still unsure why _hibernate_class can't be projected "normally".

So any information is still appreciated.

Thanks again for reading.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 31, 2008 12:54 pm 
Hibernate Team
Hibernate Team

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

the reason you cannot project on _hibernate_class is that is neither a configured indexed property nor a valid ProjectionConstant. You are basically projecting on a field which is (currently) not part of the public API. The classname is currently indexed due to the fact that it is possible to have instances of more than one entity in the same index. In this case it is of course not enough any more to just rely on the entity id.

One could argue why CLASS_FIELDNAME is not treated as ProjectionConstant as well. I don't have a clear answer for that right now.

--Hardy


Top
 Profile  
 
 Post subject: thanks
PostPosted: Sun Nov 02, 2008 7:03 am 
Beginner
Beginner

Joined: Fri Sep 26, 2008 2:39 am
Posts: 20
thanks for the answer. - i'll use the lucene document projection for now.

If the class ever gets add to the projection constants i'll change my implementation to use that.

The lucene document is loaded anyway when searching, so i guess and hope accessing it via projection will not create that much overhead - and i think it is better to access the lucenedoc then to store the objects class in another field (by using a classbridge) and accessing that field via projection.


Top
 Profile  
 
 Post subject: Unable to project "_hibernate_class" field
PostPosted: Sun Nov 09, 2008 9:48 am 
Newbie

Joined: Sun Nov 09, 2008 9:43 am
Posts: 2
+1 to expose managed object class via a Projection constant


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 09, 2008 10:56 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
You should create a Jira issue for it then.


Top
 Profile  
 
 Post subject: JIRA created
PostPosted: Sun Nov 09, 2008 11:17 am 
Newbie

Joined: Sun Nov 09, 2008 9:43 am
Posts: 2
Done.

http://opensource.atlassian.com/project ... SEARCH-296


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