Spring data JPA only one composite key is auto incremented issue

后端 未结 2 1972
忘了有多久
忘了有多久 2021-01-16 10:58

I am using MySQL database.

In my table i there are two four primary keys, out of which one is auto incremented.

@Embeddable
    public class Employee         


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-16 11:29

    You're missing a @GeneratedValue at the id field. Depending on its values, you're free to choose a strategy for generation, like a sequences, id tables, an automatic internal id generation. Last but not least GenerationType.AUTO will choose one of the mentioned strategies. See the Javadocs for javax.persistence.GeneratedValue and javax.persistence.GenerationType.

提交回复
热议问题