-->
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: JPA Lifecycle methods not allowing update to association
PostPosted: Thu Jan 05, 2012 10:15 am 
Newbie

Joined: Thu Jan 05, 2012 10:05 am
Posts: 1
I have a domain object with several transient fields that contain complex POJOs. When the domain object is saved, I want to serialize these objects to XML (using Xstream), and store them into a PersistentMap in my database.

So I created a @PrePersist/@PreUpdate method on my domain object, and in those methods serialize the values and place them into the persistent map in the domain object. When the em.merge () is called, I can see the values get serialized, the map gets updated, but the actual values saved are the original values, not the updated ones.

From drilling into the Hibernate source, it appears that after the @PreUpdate, the default event handler for merge events copies the original associations over the ones that I changed in my PreUpdate method.

I've also tried using the Hibernate Interceptors and overriding the onSave method, but the result is that same (all of the relationships get copied from the original object to the result object, thus overwriting my changes).

Is this supposed to work this way? Is there some setting I can make in the configuration that will alter this behaviour? Is there some other way to accomplish what I need to do?

Any pointers would be greatly appreciated.

Thanks


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.