Hibernate exception with @MapsId, @EmbeddedId

前端 未结 4 1328
一整个雨季
一整个雨季 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条回答
  •  不要未来只要你来
    2021-02-09 02:45

    Solution Here: Got the same problem, and got it working now.

    For it to work, the EmployeeId of your Employee class should be instantiated either in the constructor of Employee, or in the SessionBean before making the persistence.

    Otherwise, it tries to populates the values of your embeddedid with it being null.

    Not sure if this is normal or if it's a bad implementation of JPA specifications. I think the latter since the constructor for your PK is defined and hibernate should be able to call it by itself.

提交回复
热议问题