Hibernate version: 3
I have two tables in Oracle 10g linking via foreign key.
The ???.hbm.xml is generated myeclipseide.
How to fix this error?
Foreign key (FK9DB7177B3984DB05:FUNCTIONS [PROGRAM_HREF])) must have same number of columns as the referenced primary key (ROLE_PROGRAM [PROGRAM_HREF,ROLE_HREF,USERNM])
Thanks
<hibernate-mapping package="com.erp.hibernate.user">
<class name="Functions" table="FUNCTIONS">
<composite-id name="id" class="FunctionsKey">
<key-property name="functionHref" column="FUNCTION_HREF" type="java.lang.String"/>
<key-many-to-one name="roleProgram2" column="PROGRAM_HREF" class="RoleProgram"/>
<key-many-to-one name="roleProgram1" column="ROLE_HREF" class="RoleProgram"/>
<key-many-to-one name="roleProgram" column="USERNM" class="RoleProgram"/>
</composite-id>
<property name="messageKey" column="MESSAGE_KEY" type="java.lang.String" not-null="true" />
<property name="creationDate" column="CREATION_DATE" type="java.util.Date" not-null="true" />
<property name="createdBy" column="CREATED_BY" type="java.lang.String" not-null="true" />
<property name="lastUpdateDate" column="LAST_UPDATE_DATE" type="java.util.Date" not-null="true" />
<property name="lastUpdatedBy" column="LAST_UPDATED_BY" type="java.lang.String" not-null="true" />
</class>
</hibernate-mapping>
<hibernate-mapping package="com.erp.hibernate.user">
<class name="RoleProgram" table="ROLE_PROGRAM">
<composite-id name="id" class="RoleProgramKey">
<key-property name="programHref" column="PROGRAM_HREF" type="java.lang.String"/>
<key-many-to-one name="userRole1" column="ROLE_HREF" class="UserRole"/>
<key-many-to-one name="userRole" column="USERNM" class="UserRole"/>
</composite-id>
<property name="messageKey" column="MESSAGE_KEY" type="java.lang.String" not-null="true" />
<property name="creationDate" column="CREATION_DATE" type="java.util.Date" not-null="true" />
<property name="createdBy" column="CREATED_BY" type="java.lang.String" not-null="true" />
<property name="lastUpdateDate" column="LAST_UPDATE_DATE" type="java.util.Date" not-null="true" />
<property name="lastUpdatedBy" column="LAST_UPDATED_BY" type="java.lang.String" not-null="true" />
<set name="functionsSet" inverse="true">
<key column="USERNM"/>
<one-to-many class="Functions"/>
</set>
<set name="functions1Set" inverse="true">
<key column="ROLE_HREF"/>
<one-to-many class="Functions"/>
</set>
<set name="functions2Set" inverse="true">
<key column="PROGRAM_HREF"/>
<one-to-many class="Functions"/>
</set>
</class>
</hibernate-mapping>
CREATE TABLE role_program (
usernm VARCHAR2(8) NOT NULL,
role_href VARCHAR2(64) NOT NULL,
program_href VARCHAR2(64) NOT NULL,
message_key VARCHAR2(64) NOT NULL,
creation_date DATE NOT NULL,
created_by VARCHAR2(8) NOT NULL,
last_update_date DATE NOT NULL,
last_updated_by VARCHAR2(8) NOT NULL,
CONSTRAINT pk_role_program primary key (usernm, role_href, program_href),
CONSTRAINT fk_role_program foreign key (usernm, role_href) REFERENCES user_role (usernm, role_href)
) ;
CREATE TABLE functions (
usernm varchar(8) NOT NULL,
role_href VARCHAR(64) NOT NULL,
program_href VARCHAR(64) NOT NULL,
function_href VARCHAR(64) NOT NULL,
message_key VARCHAR(64) NOT NULL,
creation_date DATE NOT NULL,
created_by VARCHAR(8) NOT NULL,
last_update_date DATE NOT NULL,
last_updated_by VARCHAR(8) NOT NULL,
CONSTRAINT pk_functions primary key (usernm, role_href, program_href, function_href),
CONSTRAINT fk_functions foreign key (usernm, role_href, program_href) REFERENCES role_program (usernm, role_href, program_href)
) ;
|