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?
|