Hi
I can reproduce this issue with the following mini table model (Oracle DDL).
Thanks in advance for help.
Fab
The table DESCRIPTION has a foriegn key defined on the tables ROLE and RULETYPE:
Code:
create table DESCRIPTION (
DESCRIPTION_ID NUMBER(38,0) not null,
"DESCRIPTOR" VARCHAR2(64) not null,
KNOWN_FROM DATE not null,
KNOWN_TO DATE null,
VALID_FROM DATE not null,
VALID_TO DATE null,
MUTATION_ID NUMBER(38,0) not null,
VALIDITYCODE CHAR(1) null,
LANGUAGE_ID NUMBER(38,0) not null,
FOREIGNTABLE_ID NUMBER(38,0) not null,
FOREIGNNODE_ID NUMBER(38,0) null,
SUMMARY VARCHAR2(256) not null,
FULLTEXT VARCHAR2(2000) null, constraint DESCRIPTION_PK primary key (DESCRIPTION_ID) );
create table ROLE (
ROLE_ID NUMBER(38,0) not null,
KNOWN_FROM DATE not null,
KNOWN_TO DATE null, constraint ROLE_PK primary key (ROLE_ID) );
create table RULETYPE (
RULETYPE_ID NUMBER(38,0) not null,
"DESCRIPTOR" VARCHAR2(64) not null,
KNOWN_FROM DATE not null,
KNOWN_TO DATE null,
VALID_FROM DATE not null,
VALID_TO DATE null,
RULELEVEL CHAR(1) null, constraint RULETYPE_PK primary key (RULETYPE_ID) );
alter table DESCRIPTION
add constraint RULETYPE_DESC_FK1 foreign key (
FOREIGNNODE_ID)
references RULETYPE (
RULETYPE_ID);
alter table DESCRIPTION
add constraint ROLE_DESC_FK1 foreign key (
FOREIGNNODE_ID)
references ROLE (
ROLE_ID);
Here my Middlegen ant target (without taskdef):Code:
<target
name="test.middlegen"
description="Run Middlegen and generate Hibernate mapping files.">
<middlegen
appname="Toolset"
prefsdir="${basedir}/test_prefs"
xmlprefs="true"
databaseurl="${db.url}"
gui="true"
schema="mySchema"
driver="oracle.jdbc.driver.OracleDriver"
username="USER"
password="PASSWORD">
<table name="DESCRIPTION"/>
<table name="ROLE"/>
<table name="RULETYPE"/>
<hibernate
destination="${test.dir}"
databaseSchema="mySchema"
package="mytest.server.persistence.mapping"/>
</middlegen>
</target>
Here comes the pref file of middlegen:Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE preferences SYSTEM 'http://java.sun.com/dtd/preferences.dtd'>
<preferences EXTERNAL_XML_VERSION="1.0">
<root type="user">
<map />
<node name="middlegen">
<map />
<node name="Toolset">
<map />
<node name="hibernate">
... I removed table description ...
</node>
<node name="relations">
<map />
<node name="ROLE-DESCRIPTION">
<map />
<node name="DESCRIPTION-has-ROLE">
<map>
<entry key="target-many" value="false" />
<entry key="enabled" value="false" />
</map>
</node>
<node name="ROLE-has-DESCRIPTION">
<map>
<entry key="target-many" value="true" />
<entry key="enabled" value="true" />
</map>
</node>
</node>
<node name="RULETYPE-DESCRIPTION">
<map />
<node name="DESCRIPTION-has-RULETYPE">
<map>
<entry key="target-many" value="false" />
<entry key="enabled" value="false" />
</map>
</node>
<node name="RULETYPE-has-DESCRIPTION">
<map>
<entry key="target-many" value="true" />
<entry key="enabled" value="true" />
</map>
</node>
</node>
</node>
... table location in the gui ...
</node>
</node>
</root>
</preferences>
Here comes the mapping file for the table DESCRIPTION, which middelgen has generated.
As you can see, the property FOREIGNNODE_ID is declared twice in the file. The generated Java class has then twice the property + setter/getter.Code:
<hibernate-mapping>
<class
name="mytest.server.persistence.mapping.Description"
table="DESCRIPTION"
schema="mySchema"
>
<id
name="descriptionId"
type="java.math.BigDecimal"
column="DESCRIPTION_ID"
>
<generator class="assigned" />
</id>
... properties not involved in the mapping are removed ...
<!-- Associations -->
<property
name="foreignnodeId"
column="FOREIGNNODE_ID"
type="java.math.BigDecimal"
length="38"
>
</property>
<property
name="foreignnodeId"
column="FOREIGNNODE_ID"
type="java.math.BigDecimal"
length="38"
>
</property>
</class>
</hibernate-mapping>
Mapping for the ROLE table:Code:
<hibernate-mapping>
<class
name="mytest.server.persistence.mapping.Role"
table="ROLE"
schema="TMS"
>
<id
name="roleId"
type="java.math.BigDecimal"
column="ROLE_ID"
>
<generator class="assigned" />
</id>
... properties not involved in the mapping are removed ...
<!-- Associations -->
<!-- uni-directional one-to-many association to Description -->
<set
name="descriptions"
lazy="true"
cascade="none"
>
<key>
<column name="FOREIGNNODE_ID" />
</key>
<one-to-many
class="mytest.server.persistence.mapping.Description"
/>
</set>
</class>
</hibernate-mapping>
Mapping for the RULETYPE table:Code:
<hibernate-mapping>
<class
name="mytest.server.persistence.mapping.Ruletype"
table="RULETYPE"
schema="TMS"
>
<id
name="ruletypeId"
type="java.math.BigDecimal"
column="RULETYPE_ID"
>
<generator class="assigned" />
</id>
... properties not involved in the mapping are removed ...
<!-- Associations -->
<!-- uni-directional one-to-many association to Description -->
<set
name="descriptions"
lazy="true"
cascade="none"
>
<key>
<column name="FOREIGNNODE_ID" />
</key>
<one-to-many
class="mytest.server.persistence.mapping.Description"
/>
</set>
</class>
</hibernate-mapping>