[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3160?page=c...
]
Josh Moore commented on HHH-3160:
---------------------------------
We've run into this problem on Postgres <8.4, which does not support deferred
unique constraints yet. I'll attach one possible workaround, which for the updates:
update groupexperimentermap set child=7204, child_index=0 where id=7561;
update groupexperimentermap set child=7204, child_index=2 where id=7563;
where groupexperimentermap has a constraint "UNIQUE (child, child_index)" first
moves any constraint violating rows to child_index = -1.
Would it be possible for Hibernate to do the same?
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
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:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira