-->
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: many to many , xdoclet dublicate entry problem:
PostPosted: Fri Jun 02, 2006 7:57 am 
Newbie

Joined: Fri Jun 02, 2006 7:34 am
Posts: 3
The following definitions:

(snipped)UserRole.java

private List users = new ArrayList();

/**
* @hibernate.list name="users" table="USER_ROLE_MAP" cascade="none"
* @hibernate.collection-many-to-many class="user.model.User" column="USER_FK"
* @hibernate.collection-key column="ROLE_FK"
* @hibernate.collection-index column="USER_IDX"
* @return

The hibernate file (User.hbm.xml), created by Xdoclet snipped:
<list name="userRoles" table="USER_ROLE_MAP" lazy="false" inverse="false" cascade="none">
<key column="USER_FK"></key>
<index column="ROLE_IDX"/>
<many-to-many class="user.model.UserRole" column="ROLE_FK" outer-join="auto"/>
</list>



User.java

private List userRoles = new ArrayList();
/**
* @hibernate.list name="userRoles" table="USER_ROLE_MAP" cascade="none"
* @hibernate.collection-many-to-many class="user.model.UserRole" column="ROLE_FK"
* @hibernate.collection-key column="USER_FK"
* @hibernate.collection-index column="ROLE_IDX"
* @return
*/


The hibernate file (UserRole.hbm.xml), created by Xdoclet snipped:
<list name="users table="USER_ROLE_MAP" lazy="false" inverse="false" cascade="none">
<key column="ROLE_FK"></key>
<index column="USER_IDX"/>
<many-to-many class="user.model.User" column="USER_FK" outer-join="auto"/>
</list>



Cause this error when a USER_ROLE record is inserted:

Hibernate: insert into USER_ROLE_MAP (ROLE_FK, USER_IDX, USER_FK) values (?, ?, ?)
Hibernate: insert into USER_ROLE_MAP (USER_FK, ROLE_IDX, ROLE_FK) values (?, ?, ?)
ERROR main org.hibernate.util.JDBCExceptionReporter , - null, message from server: "Duplicate entry '1-0' for key 1"


It tries to insert 2 records instead of one like what I expected:
Hibernate: insert into USER_ROLE_MAP (USER_FX,ROLE_FK, USER_IDX, ROLE_IDX) values (?,?, ?, ?)


does someone has any idea?


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.