openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daryl Stultz <da...@6degrees.com>
Subject Re: How to update Many-to-one relationship ?
Date Thu, 04 Mar 2010 13:28:48 GMT
On Thu, Mar 4, 2010 at 8:02 AM, Himadri <hima_das@yahoo.co.in> wrote:

> I need to update Book1 to point to another Author1.
> I have tried using em.merge(Book) with CascadeType.MERGE but it doesnt
> work.
> It should work.
>
> I don't believe you have to do anything special. You don't need any
CascadeType settings since you are modifying the book directly (not trying
to save properties of the Author). If you just do
book.setAuthor(differentAuthor) and merge, it should work. (I don't use the
L2 cache, so I don't bother managing the inverse relation.) If not, perhaps
it's a transaction issue or a dirty-tracking issue. I have found that if you
change a property of an entity while it is attached to em1, then you detach
it and merge it on em2, the change does not take.

-- 
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:daryl@6degrees.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message