I've a class item with a composite id who have a relationship with concreto. Only one column of id have relationship with concreto. The other column of id is relatred with another table.
TABLE Concreto
CODIGO_CONC NUMBER(6,0) NOT NULL,
...
PRIMARY KEY ( CODIGO_CONC )
TABLE item_compra
CODIGO_CONC NUMBER(6,0) NOT NULL,
CODIGO_COMP NUMBER(6,0) NOT NULL
...
PRIMARY KEY ( CODIGO_CONC, CODIGO_COMP )
FOREIGN KEY ( CODIGO_CONC ) REFERENCES concreto ( CODIGO_CONC )
FOREIGN KEY ( CODIGO_COMP ) REFERENCES compra ( CODIGO_COMP )
);
the map file is:
<composite-id name="Item_CompraPK" class="Item_CompraPK">
<key-property name="codigoConc" column="Codigo_Conc" type="Int"/>
<key-property name="codigoComp" column="Codigo_Comp" type="Int"/>
</composite-id>
<one-to-one name="concreto" class="exemplo.Concreto"/>
I'm receiving the follow erro:
broken column mapping for: concreto.id of: Item_Compra...
I believe the problem is that hibernate try to get concreto based on the two columns of composite id. It's should be done with just the Codigo_Conc column that is the relationship column between concreto and item.
How can I fix the problem? How can I map a one-to-one relationship based in just one of the columns of a composite id?
|