-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem involving many-to-many mapping
PostPosted: Fri Sep 17, 2004 10:43 am 
Newbie

Joined: Fri Sep 17, 2004 10:03 am
Posts: 2
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.