[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3160?page=c...
]
Gail Badner updated HHH-3160:
-----------------------------
Description:
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.
was:
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 either define the
constraint on (owner_id, position) in the child entity table as deferred. If this is not
on option for a particular Dialect, the constraint on (owner_id, position) will have to be
excluded.
For a one-to-many list association on a join table, the workaround is to either define the
constraint on (child_id) in the join table as deferred. If this is not on option for a
particular Dialect, the constraint on (child_id) will have to be excluded.
I made corrections to the workaround in the Description section.
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