-->
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: Delete problem in multi-user environment
PostPosted: Thu Oct 02, 2008 8:45 am 
Newbie

Joined: Thu Oct 02, 2008 6:46 am
Posts: 5
I am new to Hibernate and want to use it in a Swing application. My problem is that I don't know how to deal with changes made by other users properly.

For example, consider a parent-child relationship and that another user has added (or deleted) a child since I loaded the objects from the database. If I now try to delete the parent object, Hibernate will delete its child objects first, but since the database has changed, my transaction will fail with a ConstraintViolationException (or StaleStateException).

One solution I can think of is to make the database responsible for handling the deletion of children, by using on-delete="cascade".

However, if parent and children belong to the same table (a tree), I cannot use this technique, because our database, MSSQL 2000, does not support cascading deletes on self-referencing tables.

Are there any alternatives? Should I tell a parent to update its view of its children before deleting it? How would I do that?


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.