Hi, Is there any particular reason that 1 entity can not have 2 references of another table, ie, the entity has FK aID1 and aID2 that refers to different records of another table? I checked the hibernate 3.2 implementation in
org.hibernate.mapping.PersistentClass.checkPropertyDuplication
Seems to me that it is only using local data structure to make sure no 2 referenced tables are of the same name.
thank you for any hints
[b]Hibernate version: 3.2 [/b]
[b]Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="popclonerecords.Mytest" table="mytest">
<id name="id" column="id" type="integer" unsaved-value="0">
<generator class="increment"/>
</id>
<many-to-one
name="testBranch"
column="t1ID"
class="popclonerecords.TestBranch"
not-null="true" />
<many-to-one
name="testBranch"
column="t2ID"
class="popclonerecords.TestBranch2"
not-null="true" />
</class>
</hibernate-mapping>
[/b]
[b]Code between sessionFactory.openSession() and session.close():
TestBranch tb = new TestBranch();
TestBranch2 tb2 = new TestBranch2();
Mytest cmap = new Mytest();
cmap.setTestBranch(tb);
cmap.setTestBranch2(tb2);
[/b]
[b]Full stack trace of any exception that occurs:
The exception is org.hibernate.MappingException:
org.hibernate.MappingException: Duplicate property mapping of testBranch found in mypack.Mytest
org.hibernate.mapping.PersistentClass.checkPropertyDuplication(PersistentClass.java:459)
org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:449)
org.hibernate.mapping.RootClass.validate(RootClass.java:192)
org.hibernate.cfg.Configuration.validate(Configuration.java:1102)
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
popclonerecords.TestParentChild.main(TestParentChild.java:156)
[/b]
[b]Name and version of the database you are using:[/b]
MySQL 4.0.27
[b]The generated SQL (show_sql=true):[/b]
[b]Debug level Hibernate log excerpt:[/b]
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp