I am trying to customize my entity to allow pks. My database consists of two fields,
dealer_detail_id pk user_detail_id pk
Both join the identifier in the corresponding tables.
I have tried this so far without success.
@Embeddable public class DealerUserPk implements Serializable { private Integer dealerDetail; private Integer userDetail;
Dealeruser
@Embeddable @Table(name = "dealer_user", schema = "account") public class DealerUser implements Serializable { @EmbeddedId private DealerUserPk id; @Id @ManyToOne @JoinColumn(name = "dealer_detail_id", referencedColumnName = "id") private DealerDetail dealerDetail; @Id @ManyToOne @JoinColumn(name = "user_detail_id", referencedColumnName = "id") private UserDetail userDetail;
DealerDetail
@Entity @Table(name = "dealer_detail", schema = "account") public class DealerDetail implements Serializable { @Id private Integer id;
Userdetail
@Entity @Table(name = "user_detail", schema = "account") public class UserDetail implements Serializable { @Id private Integer id;
Can anyone understand what I'm doing wrong?
source share