@GeneratedValue(strategy = GenerationType.AUTO) not working as thought

前端 未结 7 976
予麋鹿
予麋鹿 2020-12-14 18:09

I\'m trying to persist an object to a database. Keep getting \'Column ID cannot accept null value error\'. My object looks like this:

    @Entity
public cl         


        
7条回答
  •  自闭症患者
    2020-12-14 18:34

    You may use GenerationType.TABLE. That way, jpa uses a sequence table for id assigment and you may never need to generate sequence or auto-increment values or triggers that lowers portability.

    Also note that in java int type is initiated with 0 default, so you may get rid of that also.

提交回复
热议问题