0

是否可以在 Hibernate HBM 映射文件中使用多个组件作为复合 ID?在下面的代码段中,TradeServiceId 和 ChargeId 是实际的类。

我希望这两个字段成为该表的复合主键

    <component name="tradeServiceId" class="com.ucpb.tfs.domain.service.TradeServiceId" insert="false" update="false">
        <property name="tradeServiceId" column="serviceInstructionId" type="string" />
    </component>

    <component name="chargeId" class="com.ucpb.tfs.domain.reference.ChargeId" insert="false" update="false">
        <property name="chargeId" column="chargeId" type="string" />
    </component>
4

1 回答 1

1

IMO 这是不可能的,因为 compositeId 仅支持 KeyProperty 和 Keyreferences。但是,可以使用 IUserType 和 ICompositeUserType,这意味着您可以自己实现转换。

于 2012-08-23T13:55:08.683 回答