Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:2.1.7
Mapping documents:
<class name="com.a2a.security.users.UserImpl" table="T_PERSONNE">
<id name="id" type="int" column="PERSONNEID">
<generator class="native"/>
</id>
<property name="login">
<column name="NOMUTILISATEUR" sql-type="VARCHAR(255)" not-null="true"/>
</property>
<property name="password">
<column name="MOTDEPASSE" sql-type="VARCHAR(255)" not-null="true"/>
</property>
<property name="firstName">
<column name="NOM" sql-type="VARCHAR(255)"/>
</property>
<property name="lastName">
<column name="PRENOM" sql-type="VARCHAR(255)"/>
</property>
<property name="mail">
<column name="EMAIL" sql-type="VARCHAR(255)"/>
</property>
<property name="active" type="boolean">
<column name="ACTIVE" sql-type="TINYINT(1)" length="1" />
</property>
<dynamic-component name="properties">
<!--property name="adresse" type="java.lang.String" column="adresse"/-->
</dynamic-component>
<set name="groups" table="T_PERSONNEGROUPE" inverse="true" lazy="true" outer-join="false">
<key column="PERSONNEID"/>
<many-to-many column="GROUPEID" class="com.a2a.security.users.GroupImpl" outer-join="false" />
</set>
<!--subclass name="com.a2a.security.users.UserImpl" /-->
</class>
Code between sessionFactory.openSession() and session.close():
oTransac=session.beginTransaction();
try{
p_oUser=getUser(p_oUser.getLogin(),true);
p_oUser.addGroup(p_oGroup);
session.update(p_oUser);
}
catch(HibernateException e){
e.printStackTrace();
}
oTransac.commit();
Full stack trace of any exception that occurs:
net.sf.hibernate.HibernateException: Found two representations of same collection: com.a2a.security.users.UserImpl.groups
at net.sf.hibernate.impl.SessionImpl.updateReachableCollection(SessionImpl.java:2890)
at net.sf.hibernate.impl.FlushVisitor.processCollection(FlushVisitor.java:32)
at net.sf.hibernate.impl.AbstractVisitor.processValue(AbstractVisitor.java:69)
at net.sf.hibernate.impl.AbstractVisitor.processValues(AbstractVisitor.java:36)
at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2612)
at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2478)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2280)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2259)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at com.a2a.security.users.dbprovider.UserDBProvider.joinGroup(UserDBProvider.java:559)
at com.a2a.security.users.UserProviderFactory.joinGroup(UserProviderFactory.java:364)
at com.a2a.security.users.testusers.TestUserDBProvider.testJoinGroupUser(TestUserDBProvider.java:231)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Name and version of the database you are using:MySQL 4.0.20
The generated SQL (show_sql=true):
select this.PERSONNEID as PERSONNEID1_,
this.NOMUTILISATEUR as NOMUTILI2_1_,
this.MOTDEPASSE as MOTDEPASSE1_,
this.NOM as NOM1_,
this.PRENOM as PRENOM1_,
this.EMAIL as EMAIL1_,
this.ACTIVE as ACTIVE1_,
groups1_.PERSONNEID as PERSONNEID__,
groups1_.GROUPEID as GROUPEID__,
groupimpl2_.GROUPEID as GROUPEID0_,
groupimpl2_.NOM as NOM0_,
groupimpl2_.DESCRIPTION as DESCRIPT3_0_
from T_PERSONNE this
left outer join T_PERSONNEGROUPE groups1_ on this.PERSONNEID=groups1_.PERSONNEID
left outer join T_GROUPE groupimpl2_ on groups1_.GROUPEID=groupimpl2_.GROUPEID
where this.NOMUTILISATEUR=?
I wish to add a group but hibernate to create this exception.
if somebody finds a solution .
Thanks.