-->
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.  [ 2 posts ] 
Author Message
 Post subject: LuceneInterceptor with Hibernate
PostPosted: Wed Feb 15, 2006 6:21 am 
Newbie

Joined: Wed Feb 15, 2006 6:09 am
Posts: 3
I've created a class called LuceneInterceptor that implements org.hibernate.Interceptor. It's basically the same as the second example here:

http://www.hibernate.org/138.html

What I'm trying to do is populate the Lucene directory with a document every time an object is loaded. I've implemented onLoad but this method is called just before an object is initialized. This seems to mean that the id (primary key) of the object is set but every other parameter is null. What I want is a method that's called just after an object is initialized. Then I can return a fully populated org.apache.lucene.document.Document from the object and add it to my Lucene directory.

Has anyone else done this? It must be a common requirement to populate a directory when objects are loaded from the database.


Top
 Profile  
 
 Post subject: Re: LuceneInterceptor with Hibernate
PostPosted: Wed Feb 15, 2006 9:39 am 
Newbie

Joined: Wed Feb 15, 2006 6:09 am
Posts: 3
Ok, I've given up on the idea of using an Interceptor for this and I'm going to do it manually. I even tried iterating through the objects after I load them and saving them (since nothing will have changed it won't hit the database) but it appears onSave will only be called if it's actually going to save the object to the database.

I really think org.hibernate.Interceptor needs to be enhanced since onLoad as it is implemented now is basically useless. There needs to be an onPostLoad method and onSave/onFlushDirty methods that get called regardless of whether the object has changed and therefore is actually going to be saved to the database.


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