Hi Patric, Thats exactly what was happening. I'm using a very agile pattern of one accessors per operation, the transaction handled in the base, so I was loading the Role in one transaction and adding it to the Account in another.
I did get it working by changing the concept to one operation per accessors. However I'm thinking that if I have committed the first transaction and I now have a bean with a valid ID, OpenJPA should know what to do with it, particularly in this case where the Role is immutable (it hasn't changed). No doubt this is by design, but I think the framework could be a bit smarter about it... if the referenced class has not changed (and particularly in a many/many relation where there is a third table) the relationship should simply be persisted (governed by what ever constraints are already on the reference table). just my 2. - Brill Patrick Linskey-2 wrote: > > It sounds like your facade on top of JPA is causing the work that > you're doing to span multiple persistence contexts (multiple > transactions, basically), and thus causing the role instance to be > detached. > > Ideally, it's probably worth investigating to make sure the "right" > thing is happening wrt. your transaction boundaries. > > If you set up your cascade settings correctly, then you'll probably be > able to trivially work around the problem, but bear in mind that that > might just end up masking a larger issue. > > -Patrick > -- View this message in context: http://www.nabble.com/Help%3A-Attaching-an-already-persisted-object-to-a-new-parent.-tf4776024.html#a13677486 Sent from the OpenJPA Users mailing list archive at Nabble.com.