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