-->
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: Calling an "init" method after retrieving objects
PostPosted: Mon Oct 30, 2006 8:48 pm 
Newbie

Joined: Wed Aug 30, 2006 4:05 am
Posts: 3
I've tried searching for this in the forums but struggled a bit to come up with the right key terms, so apologies if this has been asked previously.

I want to call an "init()" method on my objects after they've been loaded by Hibernate. Does any know if this is at all possible? Can someone point me in the right direction with this?

Thanks

Mark C


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 31, 2006 12:48 am 
Beginner
Beginner

Joined: Tue Aug 22, 2006 3:06 am
Posts: 25
add init() method to the defaut constructor method.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 31, 2006 4:11 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
calling init in the constructor will then execute before the properties are actually set on the object.

you need to look into the Interceptor.onLoad or maybe add an eventlistener to get full control.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 31, 2006 7:02 pm 
Newbie

Joined: Wed Aug 30, 2006 4:05 am
Posts: 3
Thanks for the comments guys.

I was checking the JavaDoc for Interceptor.onLoad

Quote:
Called just before an object is initialized. The interceptor may change the state, which will be propagated to the persistent object. Note that when this method is called, entity will be an empty uninitialized instance of the class.


What I really need is for an Object to be populated by Hibernate and then my hooking into it. From the JavaDoc, the onLoad seems to hook in before Hibernate populates the object? Is this a correct reading?

I guess the question is, is there a plugin point in hibernate *after* the properties have been loaded? (I'm using version 2, if that makes a difference)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 01, 2006 3:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hibernate2 ? implement LifeCycle

H2 doesn't really have much extensionpoints compared to h3

_________________
Max
Don't forget to rate


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.