Hi,
We are using Hibernate 2.0.3 with Hypersonic 1.7.2 database.
We try representing a typical User / Role association with following mapping documents.
Role mapping file :
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.axway.xpm.xdk.workflow.XpmDKWfwRole" table="XPMDKWFWROLE">
<id name="roleIdTech" column="roleIdTech" type="java.lang.String" unsaved-value="null">
<generator class="uuid.hex">
</generator>
</id>
<property name="roleName" type="java.lang.String"/>
<set name="XpmUserList" cascade="all" table="user_role" inverse="true">
<key column="roleIdTech"/>
<many-to-many class="com.axway.xpm.xdk.workflow.XpmDKWfwUser" column="userIdTech"/>
</set>
</class>
</hibernate-mapping>
User mapping file :
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.axway.xpm.xdk.workflow.XpmDKWfwUser" table="XPMDKWFWUSER">
<id name="userIdTech" column="userIdTech" type="java.lang.String" unsaved-value="null">
<generator class="uuid.hex">
</generator>
</id>
<property name="userName" type="java.lang.String"/>
<property name="userPwd" type="java.lang.String"/>
<property name="userType" type="integer"/>
<set name="XpmRoleList" cascade="all" table="user_role">
<key column="userIdTech"/>
<many-to-many class="com.axway.xpm.xdk.workflow.XpmDKWfwRole" column="roleIdTech"/>
</set>
</class>
</hibernate-mapping>
We try to execute the following scenario :
adding four roles
inserting a first user associated with three roles
inserting a second user associated with the same three roles
The last action produces following exception :
com.axway.util.io.XPMException: The user user8 cannot be created : Another object was associated with this id (the object with the given id was already loaded): [com.axway.xpm.xdk.workflow.XpmDKWfwRole#2c902068fb3a12e600fb3a1398fb0003]
at com.axway.xpm.xdk.workflow.XpmDKWfwSession.addUser(XpmDKWfwSession.java:366)
at com.axway.xpm.xdk.workflow.XpmDKWfwSessionManager.addUser(XpmDKWfwSessionManager.java:167)
at com.axway.xpm.xdk.workflow.XpmDKWfwAdmManager.addUser(XpmDKWfwAdmManager.java:370)
at com.axway.xpm.xdk.workflow.XpmDKWfwMainTest.testDeDebug(XpmDKWfwMainTest.java:1318)
at com.axway.xpm.xdk.workflow.XpmDKWfwMainTest.main(XpmDKWfwMainTest.java:64)
For information, the JavaCode using Hibernate API is :
Code:
try
{
sess = sessions.openSession(DBWorkflowManager.getGestionBD(dbUrl).getWorkflowCnx4Tx());
sess.saveOrUpdate(user);
sess.flush();
sess.connection().commit();
}
catch (Exception e)
{
try
{
sess.connection().rollback();
}
catch (Exception ex)
{
// do nothing
}
throw new XPMException(e.getMessage());
}
finally
{
try
{
sess.connection().close();
}
catch (Exception ex)
{
// do nothing
}
try
{
sess.close();
}
catch (Exception ex)
{
// do nothing
}
}
Thanks.