Hi, I'm facing a big problem here and tried a lot to find the answers in the Internet but not succeeded...
I have tables where two of them have a composite PK, and the third one has two FKs point for those two PKs...
Here is the ALTER TABLE that creates the FKs
Code:
ALTER TABLE FIELD ADD CONSTRAINT FK_FIELD_DEF FOREIGN KEY (ENTITY_TYPE_NAME, FIELD_DEF_NAME) REFERENCES FIELD_DEF (ENTITY_TYPE_NAME, NAME);
ALTER TABLE FIELD ADD CONSTRAINT FK_ENTITY_MAPPING_2 FOREIGN KEY (ENTITY_TYPE_NAME, ENTITY_MAPPING_NAME) REFERENCES ENTITY_MAPPING (ENTITY_TYPE_NAME, NAME);
The problem is that one of the composite PKs fields is the same for both tables... How can I map it on Hibernate? The field table is:
Code:
CREATE TABLE FIELD (
POSITION NUMBER(4) NOT NULL,
USER_FORMAT VARCHAR(100) NOT NULL,
ENTITY_TYPE_NAME VARCHAR(100) NOT NULL,
FIELD_DEF_NAME VARCHAR(100) NOT NULL,
ENTITY_MAPPING_NAME VARCHAR(100) NOT NULL,
CONSTRAINT PK_FIELD PRIMARY KEY (ENTITY_TYPE_NAME, FIELD_DEF_NAME, ENTITY_MAPPING_NAME)
);
And my mapping file is:
Code:
<class ...>
<composite-id>
<key-many-to-one name="entityMapping" class="com.model.EntityMapping">
<column name="ENTITY_MAPPING_NAME" />
<column name="ENTITY_TYPE_NAME" />
</key-many-to-one>
<key-many-to-one name="fieldDef" class="com.model.FieldDef">
<column name="ENTITY_FIELD_NAME" />
<column name="ENTITY_TYPE_NAME" />
</key-many-to-one>
</composite-id>
<property name="position" access="field" />
<property name="userFormat" access="field" column="USER_FORMAT" />
</class>
Which returns an error:
Repeated column in mapping for entity
Thanks.