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

后端 未结 3 1673
迷失自我
迷失自我 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:46

    Put those guys

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "day_idday", nullable = false, insertable = false, updatable = false)
    private Day day;
    
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "timeslot_idtimeslot", nullable = false, insertable = false, updatable = false)
    private Timeslot timeslot;
    

    inside the PeriodId class and throw away those ints. I have done a mapping similar to yours this way and it works.

提交回复
热议问题