三列复合键和hibernate映射

时间:2013-08-05 02:55:39

标签: hibernate oracle11g

我有3张桌子:

Table A(Col1,Col2,Col3) -- Col1 Primary Key
Table B(Col4,Col5,Col6) -- (Col4,Col5) --Composite Key
Table C(Col7,Col8,Col9,Col10) --(Col7,Col8,Col9) -- Composite key References (Col1,Col4,Col5)

如何为此表C进行hibernate映射?

1 个答案:

答案 0 :(得分:0)

你能不能制作内置复合键的复合键?

这样的事情:

<composite-id name="id" class="com.domain.CompositeTableC">
    <key-property name="col1" type="string">
        <column name="Col1" length="8" />
    </key-property>
    <key-property name="col4" type="string">
        <column name="Col4" length="8" />
    </key-property>
    <key-property name="col5" type="string">
        <column name="Col5" length="8"/>
    </key-property>
</composite-id> 

上课:

public class CompositeTableC{
//constructors
private String col1;
private CompositeTableB compositeB;
//getters and setters
}

public class CompositeTableB {
//constructors
private String col4;
private String col5;
//getters and setters
}