Hi Jacek, Thanks for the reply.
Jacek Laskowski-4 wrote: > > On 4/19/07, roger.keays <[EMAIL PROTECTED]> wrote: > >> I have a list which is marked @ElementDependent and also CascadeType.ALL. >> Adding and removing items from the list works fine, and those elements >> are >> deleted from the database. When I try to delete the owning entity though, >> I >> get the exception below. > ... >> <2|false|0.9.6-incubating> >> org.apache.openjpa.persistence.OptimisticLockException: An >> optimistic lock violation was detected when flushing object instance >> >> "figbird.users.entities.RoleMapping-figbird.users.entities.RoleMapping-5" >> to the data store. This indicates that the object was concurrently >> modified >> in another >> transaction. FailedObject: >> figbird.users.entities.RoleMapping-figbird.users.entities.RoleMapping-5 > > I think I've seen the error message when @Version attributes have been > used. Do you happen to use it in the entities of yours? Could you > elaborate a bit more about your application? How does the > persistence.xml look like? Could you narrow down the issue to some > test case? > I've narrowed the problem down to a foreign key constraint. It occurs when I use a DELETE CASCADE: ALTER TABLE fb_user_roles ADD FOREIGN KEY (username) REFERENCES fb_users (username) ON DELETE CASCADE; If I use ON DELETE RESTRICT, there is a foreign key exception when deleting the user. If I use ON DELETE SET NULL, it is okay, although not that's necessarily the behaviour I'd like. This seems to be a problem with the ordering of delete statements which I have run into before: http://www.nabble.com/forum/ViewPost.jtp?post=7395124&framed=y Roger -- View this message in context: http://www.nabble.com/%40ElementDependent-and-cascade-delete-tf3604490.html#a10247539 Sent from the open-jpa-dev mailing list archive at Nabble.com.