Hibernate复合映射键

时间:2017-03-02 00:22:52

标签: java hibernate

我有* .hbm.xml

... 
<id name="id" type="java.lang.Integer" column="col1"/>

<map name="myMap" table="table1" cascade="delete" lazy="false">
    <key column="col1" />
    <composite-map-key class="MyCompositeKey">
        <key-property name="komp_key1" column="komp_key1"></key-property>
        <key-property name="komp_key2" column="komp_key2"></key-property>
    </composite-map-key>

    <many-to-many column="col2"  class="MyClass" />
</map>
...

结果我有这个约束:

CONSTRAINT relations_pkey PRIMARY KEY (entity_id, attribute_idv, entity_val)

我可以有这个约束:

CONSTRAINT relations_pkey PRIMARY KEY (entity_id, attribute_idv, entity_val, col2)

我可以将col2添加到组合键吗?

0 个答案:

没有答案