This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread 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 Android Security Essentials Live Lessons this week in the Android 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
 
Similar Threads
Composite primary key-Exception:could not resolve property
Hibernate: Criteria Query with Subselect
404 error loading
Help with Criteria API
BeanCreationException exception