复合Id的Roo注释

时间:2014-03-28 11:21:51

标签: java jpa spring-roo

如果我的类实体有超过1个PK,我应该使用标识符类还是可嵌入类(或者它是否相同)?

我在处理超过1 @RooJavaBean @Id的{​​{1}}课时遇到问题:

@RooJavaBean
// other Roo Entity Annotation
class EntityTable {

    @Id @Column(name="fk_entity_sub_one")
    private Integer fkPkOne;

    @Id @Column(name="fk_entity_sub_one")
    private Integer fkPkTwo;
}

注意:我使用原始数据类型对象而不是实体对象,因为我不需要返回地图。 (我是否有正确的想法在实体加载时节省内存?)

1 个答案:

答案 0 :(得分:0)

尝试以下命令:

   entity jpa --class ~.domain.EntityTable --identifierType ~.domain.EntityTablePk --entityName EntityTable --identifierField myPk --table TABLE
   field number --fieldName fkPkOne --type java.lang.Integer --column fk_entity_sub_one --class ~.domain.EntityTablePk
   field number --fieldName fkPkTwo --type java.lang.Integer --column fk_entity_sub_two --class ~.domain.EntityTablePk

查看JPA Documentation

相关问题