Hi,
I currently have a class Owner, with an id, a name and two sets. The first set contains the owners I can read data from, the second set contains the owners to whom I gave the rights to read my data.
Code:
Long id;
String name;
Set delegationOver;
Set delegationTo; owner has given delegation.
I'm mapping the relationship (which is a many to many from Owner to Owner) as follow:
Code:
<class name="net.actimage.contactmanagement.Owner" table="T_USER">
<id name="id" column="uid" type="long" unsaved-value="null">
<generator class="increment"/>
</id>
<property name="jahiaId" type="string"/>
<set name="contact">
<key column="user_id"/>
<one-to-many class="net.actimage.contactmanagement.Contact"/>
</set>
<set name="delegationTo" table="T_DELEGATIONS">
<key column="owner_id"/>
<many-to-many column="user_id" class="net.actimage.contactmanagement.Owner"/>
</set>
<set name="delegationOver" table="T_DELEGATIONS">
<key column="user_id"/>
<many-to-many column="owner_id" class="net.actimage.contactmanagement.Owner"/>
</set>
</class>
So I guess I did something wrong, because I get an SQL error:
Code:
[17/09/04 16:00:09:031 CEST] 5a2e267a SystemOut O Hibernate: insert into T_DELEGATIONS (owner_id, user_id) values (?, ?)
[17/09/04 16:00:09:031 CEST] 5a2e267a JDBCException W net.sf.hibernate.util.JDBCExceptionReporter SQL Error: -9, SQLState: 23000
[17/09/04 16:00:09:047 CEST] 5a2e267a JDBCException E net.sf.hibernate.util.JDBCExceptionReporter Violation of unique index: SYS_PK_T_DELEGATIONS in statement [insert into T_DELEGATIONS (owner_id, user_id) values (3, 1)]
[17/09/04 16:00:09:047 CEST] 5a2e267a JDBCException E net.sf.hibernate.util.JDBCExceptionReporter could not insert collection rows: [net.actimage.contactmanagement.Owner.delegationTo#3]
[17/09/04 16:00:09:062 CEST] 5a2e267a JDBCException E net.sf.hibernate.util.JDBCExceptionReporter TRAS0014I: Exception: java.sql.SQLException: Violation of unique index: SYS_PK_T_DELEGATIONS in statement [insert into T_DELEGATIONS (owner_id, user_id) values (3, 1)]
Could someone help me out with this?
Thanks you