-->
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: Problem with insert/delete sequence on one-to-many relations
PostPosted: Fri Feb 16, 2007 12:52 am 
Newbie

Joined: Wed Aug 24, 2005 1:43 pm
Posts: 10
Hi All,
I am having a problem with a parent-child type relationship in the following scenario:

1) parent (PK parent_id) has a one-to-many relationship with child (PK child_id), and relation is marked as lazy="false" inverse="true" cascade="all-delete-orphan"
2) there is a unique index on (parent_id, child_name) on the child table.
3) some client code that uses a detached object can delete a child object from a parent's children list, and re-add a new child object with the same name.

When hibernate merges the parent object, it tries to insert the new child first, and then delete the old child object. This results in a constraint violation from the database. If I drop the index, I see the insert going first, followed by the delete.

Should this be filed in JIRA, or is there a work around/setting to make the delete happen before the insert?

Cheers,
Seb


Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.2.1 and 3.2.2

Full stack trace of any exception that occurs:
org.hibernate.exception.ConstraintViolationException: could not insert: [com.***.***]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2263)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2656)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:52)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
...

Name and version of the database you are using: Sybase


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.