hello,
I have projects which contain SequenceLists:
Code:
@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY)
@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.ALL,
org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
private List<SequenceList> hitlists;
This is the place where SequenceLists are stored: When a project is saved,
all SequenceLists are saved along with it.
This works fine. However, now I added the Report-class which holds references
to SequenceLists:
Code:
@OneToMany
private List<SequenceList> sequencelists;
I do not cascade because these references are independent from the
Projects, where SequenceLists are stored: The Reports are like a shopping
bag: you add/remove SequenceLists (without affecting the persistence of the
objects in the project!) and then hit the "Create PDF" button.
However, with the above mapping, I cannot have two Reports which
contain the same SequenceList (which is perfectly legal according to my
understanding of @OneToMany and must be supported by the application).
Is the above mapping for "sequencelists" wrong?
On the SQL level, it seems there is a unique constraint not on the
combination of Report-id and SequenceList-id (the table for Report is oddly
named "reports2"), but on sequencelists_id(!):
select * from reports2_sequencelists;
=> yields (2,1)
insert into reports2_sequencelists (reports2_id, sequencelists_id) values (3, 1);
=> Violation of unique constraint SYS_CT_363: duplicate value(s) for column(s)
SEQUENCELISTS_ID / Error Code: -104 / State: 23000
I am running a HSQLDB-Database.
Thanks a lot in advance !!