Hibernate JPA IdentifierGenerationException: null id generated for class with @embeddedid

后端 未结 3 1671
迷失自我
迷失自我 2021-01-12 19:21

I am having trouble mapping my database domain model to the program entities in one case where the entity is essentially a join table (a period) which combines two other ent

3条回答
  •  悲哀的现实
    2021-01-12 19:30

    On a first glance, You're missing the generated value annotation in the embedded id class.

    @Embeddable
    public class PeriodId implements Serializable {
    
        @GeneratedValue
        @Column(name = "timeslot_idtimeslot")
        private int timeslotId;
    
        @GeneratedValue    
        @Column(name = "day_idday")
        private int dayId;
    
        //constructors, getters, setters, hashcode, and equals
    }
    

提交回复
热议问题