I have a table that references itself. Here is the definition:
Code:
CREATE TABLE QW_EMPLOYEE
(
EMPLOYEE_ID NUMBER,
FIRST_NAME VARCHAR2(20),
LAST_NAME VARCHAR2(30),
MANAGER_ID NUMBER
);
ALTER TABLE QW_EMPLOYEE ADD (
CONSTRAINT PK_QW_EMPLOYEE PRIMARY KEY (EMPLOYEE_ID)
);
ALTER TABLE QW_EMPLOYEE ADD (
CONSTRAINT TEST_FK FOREIGN KEY (MANAGER_ID)
REFERENCES QW_EMPLOYEE (EMPLOYEE_ID)
);
Notice that MANAGER_ID is a reference to another record in the table (the manager is also an employee!) Running this table through middlegen though produces the following file:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin
http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class
name="testQwb.hibernate.persistent.QwEmployee"
table="QW_EMPLOYEE"
>
<id
name="employeeId"
type="java.lang.Integer"
column="EMPLOYEE_ID"
>
<generator class="assigned" />
</id>
<property
name="firstName"
type="java.lang.String"
column="FIRST_NAME"
length="20"
/>
<property
name="lastName"
type="java.lang.String"
column="LAST_NAME"
length="30"
/>
<!-- associations -->
<!-- bi-directional many-to-one association to QwEmployee -->
<many-to-one
name="qwEmployee"
class="testQwb.hibernate.persistent.QwEmployee"
not-null="true"
>
<column name="MANAGER_ID" />
</many-to-one>
</class>
</hibernate-mapping>
Notice the many-to-one association. For some reason, Middlegen named the associated column "qwEmployee" instead of "managerID" or "managerIdQwEmployee" or something with at least the name "manager" in it! Is there some way in middlegen to be able to specify this, or to change the name to a more appropriate one?
Thanks and Happy New Year,
Daniel