This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Object Relational Mapping and the fly likes Hibernate Search NPE and other id errors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Search NPE and other id errors" Watch "Hibernate Search NPE and other id errors" New topic
Author

Hibernate Search NPE and other id errors

Bai Shen
Ranch Hand

Joined: Sep 24, 2008
Posts: 323
I have object A, which is an abstract class. It has concrete implementations A1, A2, etc. They are all mapped using the same hbm.xml file, with each class using separate tables.

I'm trying to implement Hibernate Search. I added @Indexed and @DocumentId to A1, A2, etc, but not A. A does have an id, which ends up being the same as the ones for the subclasses.

Whenever I run my program, I get errors about the id being null. This is without calling anything specific to the search. I'm not sure why it can't find the id of the object.




If I actually try and do a search, I get the following error. ContextUtil is a context listener and I'm just using it to make sure my test code runs at server startup.


It seems that the translation from the lucene query to the hibernate one isn't properly mapping the fields.


Any help would be appreciated.

TIA.
Bai Shen
Ranch Hand

Joined: Sep 24, 2008
Posts: 323
Okay, I fixed the search error. I had to move the @DocumentId tag from the concrete subclasses to the abstract superclass.

But I'm still getting the NPE whenever I do anything with the database. Any ideas why?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate Search NPE and other id errors