问题描述
当我拥有其他实体的两个属性作为实体的主键时,我可以让其他实体实例直接成为该实体的成员:
@Entity
public class Position {
@EmbeddedId
private PositionKey positionKey;
@MapsId("accountCode")
@ManyToOne(fetch = FetchType.LAZY)
private Account account;
@MapsId("productId")
@ManyToOne(fetch = FetchType.LAZY)
private Product product;
}
@Embeddable
public class PositionKey {
private String accountCode
private Logn productId;
}
现在,假设嵌入的id是两种简单的类型:
@Entity
public class Position {
@EmbeddedId
private PositionKey positionKey;
// how can I have this here? @MapsId doesn't work
private String accountCode;
// how can I have this here? @MapsId doesn't work
private Integer productId;
}
@Embeddable
public class PositionKey {
private String accountCode
private Long productId;
}
使用@EmbeddedId,是否可以在Position类上具有accountCode和productId属性?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)