我必须将composite-id(xml)重写为JPA

时间:2015-05-06 11:24:08

标签: xml hibernate jpa annotations composite-id

这是我的xml映射。我需要制作JPA映射

    

    <composite-id>
        <key-property name="systemId" type="integer" column="SYSTEM_ID"/>
        <key-property name="rollingRackId" type="integer" column="ROLLING_RACK_ID"/>
    </composite-id>

    <property name="status" type="integer" column="ROLLING_RACK_STATUS"/>
    <property name="changeTime" type="timestamp" column="CHANGE_TIME" />

</class>

1 个答案:

答案 0 :(得分:1)

您必须引入Id类

@Entity @IdClass(KeyClass.class)
public class Entity{
    @Id int systemId;
    @Id int rollingRackId;

}


class KeyClass{
    int systemId;
    int rollingRackId;
}