Hibernate exception with @MapsId, @EmbeddedId

前端 未结 4 1261
一整个雨季
一整个雨季 2021-02-09 01:58

I\'ve got a problem with @MapsId annotation and @EmbeddedId. When running a code in Hibernate I get:

Caused by: org.hibernate.Pr

4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-09 02:31

    its an old but might be useful for some one

    try to

    @Entity
    public class Employee implements Serializable {
    
    @EmbeddedId
    private EmployeeId id;
    
    private String firstName;
    
    @ManyToOne
    @MapsId("id")
    @JoinColumn(name ="serverId")
    private Server server;
    
    @OneToOne
    @MapsId("id")
    @JoinColumn(name= "websiteId")
    private Website website;
    

提交回复
热议问题