-->
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.  [ 1 post ] 
Author Message
 Post subject: @PreUpdate and other callbacks: what is allowed in them?
PostPosted: Mon Mar 12, 2007 5:05 pm 
Newbie

Joined: Mon Dec 18, 2006 9:50 am
Posts: 2
I have read in the hibernate docs that it is not allowed to use EntityManager methods from these callbacks.

Is the current ("this") entity "managed" during the execution of the @PreUpdate annotated method?

Is it allowed to change (non-transient) fields of the current (this) entity in these methods? Will these changes be stored? Will the @PreUpdate method be called again for these changes and by that create some kind of recursion?

Is it allowed to change (non-transient) fields of other entities in these methods? Accessing these other entities is done through the OO relationships of the current (this) entity.

I got some inconsistent results... In fact, changing values of fields of the current entity WORKED WELL and the fields changed in the DB, with no recursion of the @PreUpdate method. However, changing fields of other entities... well... it sometimes works and sometimes doesn't. It's as if sometimes (I have a few guesses about when) the related entities (of the one that the @PreUpdate method is invoked upon) are managed, and sometimes they are not.

Can someone direct me to a set of deterministic UNequivocal rules regarding Do-s and Don't Do-s on these entity callbacks?

Thanks!

-------------------
Amit Kasher


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.