Hibernate version: 3.2.2
Hibernate Tools version: 3.2.0.beta9a
Name and version of the database: MySQL version 5.1.17
The problem I am having is that the hibernate tools do not seem to be recognizing thecomposite foreign keys that I have in my tables and seem to be treating them as just regular properties ... to illustrate more clearly what I mean below are a couple of my tables and the resulting hibernate mapping files:
The tables:
Code:
CREATE TABLE USER_ROLE (
INTERNAL_NAME VARCHAR(255),
DISPLAY_NAME_F VARCHAR(255),
DESCRIPTION_E VARCHAR(255),
DESCRIPTION_F VARCHAR(255),
USER_ROLE_ID INT NOT NULL,
USER_ROLE_RS_CODE INT NOT NULL,
USER_ROLE_RS_DATE DATETIME NOT NULL,
USER_ROLE_RS_USER VARCHAR(35) NOT NULL,
DISPLAY_NAME_E VARCHAR(255) NOT NULL,
CONSTRAINT USER_ROLE_PID PRIMARY KEY (USER_ROLE_ID,USER_ROLE_RS_CODE))ENGINE=INNODB ;
CREATE TABLE USER (
USER_ID INT NOT NULL,
USER_RS_CODE INT NOT NULL,
USER_RS_DATE DATETIME NOT NULL,
USER_RS_USER VARCHAR(35) NOT NULL,
USERNAME VARCHAR(35) NOT NULL,
PASSWORD VARCHAR(35) NOT NULL,
USER_ROLE_ID INT,
USER_ROLE_RS_CODE INT,
USER_IS_ACTIVE BOOLEAN NOT NULL,
CONSTRAINT USER_PID PRIMARY KEY (USER_ID,USER_RS_CODE),
CONSTRAINT PRIMARY_ROLE_FK FOREIGN KEY(USER_ROLE_ID,USER_ROLE_RS_CODE) REFERENCES USER_ROLE(USER_ROLE_ID,USER_ROLE_RS_CODE))ENGINE=INNODB ;
Here are the generated mapping files:
UserRole.hbm.xml:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jun 4, 2007 11:12:30 AM by Hibernate Tools 3.2.0.b9 -->
<hibernate-mapping>
<class name="reverseRFI.UserRole" table="user_role">
<comment></comment>
<composite-id name="id" class="reverseRFI.UserRoleId">
<key-property name="userRoleId" type="int">
<column name="USER_ROLE_ID" />
</key-property>
<key-property name="userRoleRsCode" type="int">
<column name="USER_ROLE_RS_CODE" />
</key-property>
</composite-id>
<property name="internalName" type="string">
<column name="INTERNAL_NAME">
<comment></comment>
</column>
</property>
<property name="displayNameF" type="string">
<column name="DISPLAY_NAME_F">
<comment></comment>
</column>
</property>
<property name="descriptionE" type="string">
<column name="DESCRIPTION_E">
<comment></comment>
</column>
</property>
<property name="descriptionF" type="string">
<column name="DESCRIPTION_F">
<comment></comment>
</column>
</property>
<property name="userRoleRsDate" type="timestamp">
<column name="USER_ROLE_RS_DATE" length="19" not-null="true">
<comment></comment>
</column>
</property>
<property name="userRoleRsUser" type="string">
<column name="USER_ROLE_RS_USER" length="35" not-null="true">
<comment></comment>
</column>
</property>
<property name="displayNameE" type="string">
<column name="DISPLAY_NAME_E" not-null="true">
<comment></comment>
</column>
</property>
</class>
</hibernate-mapping>
User.hbm.xml:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jun 4, 2007 11:12:30 AM by Hibernate Tools 3.2.0.b9 -->
<hibernate-mapping>
<class name="reverseRFI.User" table="user">
<comment></comment>
<composite-id name="id" class="reverseRFI.UserId">
<key-property name="userId" type="int">
<column name="USER_ID" />
</key-property>
<key-property name="userRsCode" type="int">
<column name="USER_RS_CODE" />
</key-property>
</composite-id>
<property name="userRsDate" type="timestamp">
<column name="USER_RS_DATE" length="19" not-null="true">
<comment></comment>
</column>
</property>
<property name="userRsUser" type="string">
<column name="USER_RS_USER" length="35" not-null="true">
<comment></comment>
</column>
</property>
<property name="username" type="string">
<column name="USERNAME" length="35" not-null="true">
<comment></comment>
</column>
</property>
<property name="password" type="string">
<column name="PASSWORD" length="35" not-null="true">
<comment></comment>
</column>
</property>
<property name="userRoleId" type="java.lang.Integer">
<column name="USER_ROLE_ID">
<comment></comment>
</column>
</property>
<property name="userRoleRsCode" type="java.lang.Integer">
<column name="USER_ROLE_RS_CODE">
<comment></comment>
</column>
</property>
<property name="userIsActive" type="byte">
<column name="USER_IS_ACTIVE" not-null="true">
<comment></comment>
</column>
</property>
</class>
</hibernate-mapping>
Thanks for any help.