]
Josh Moore updated HHH-3160:
----------------------------
Attachment: workaround.sql
Workaround via triggers which checks for any unique constraint violations and performs an
extra "UPDATE" statement to change the column used for ordering (here:
child_index) to -1.
Support one-to-many list associations with constraints on both
(owner_id, position) and (child_id)
--------------------------------------------------------------------------------------------------
Key: HHH-3160
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3160
Project: Hibernate3
Issue Type: Sub-task
Reporter: Gail Badner
Assignee: Gail Badner
Attachments: workaround.sql
The logic used for removing entities from one-to-many list associations can cause
ConstraintViolationException will be thrown if there are constraints on both (owner_id,
position) and (child_id) in the "collection table". If the association is on a
join table, the "collection table" is the join table; otherwise, the
"collection table" is the child entity table..
Currently, SchemaExport does not put a constraint on (owner_id, position) when exporting
one-to-many list associations on a foreign key. SchemaExport should be updated to also
export this constraint.
See HHH-1268 for a description of how to reproduce this issue.
For one-to-many list associations on a foreign key, the workaround is to define the
unique constraint on (owner_id, position) in the child entity table as deferred. It is
assumed that the primary key in the child entity table is the child ID.
For a one-to-many list association on a join table, the workaround is to define the
constraint on (child_id) in the join table as deferred. It is assumed that the primary key
in the join table is (owner_id, position).
If your Dialect does not support deferred constraints, then the only workaround is to
exclude the unique constraint.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: