PersistenceException: ERROR executing DML bindLog[] error[Field 'id' doesn't have a default value]

て烟熏妆下的殇ゞ 提交于 2020-01-05 02:42:47

问题


I'm trying to use MySQL and ebeans for saving my tasks. When i apply the script, i get this error :

[PersistenceException: ERROR executing DML bindLog[] error[Field 'id' doesn't have a default value]]

Before using MySQL as DB, it worked fine with H2 DB in memory as well as File system...

How can I resolve this error?


回答1:


just got the same error. add AUTO_INCREMENT to your id field and the constraint in your evolution script.Like this

   create table name (
  id                        bigint not null AUTO_INCREMENT,
  ...
  constraint pk_name primary key (id),

);

now it works

EDIT: if you annotate the field 'id' in the model with @Id evolutions should automatically add AUTO_INCREMENT and the constraint




回答2:


I just encountered this error and in my case, the database already exists as part of my earlier efforts getting my app set up, but half the tables had AI set for the id field, but the other half didn't.

I'm not sure why this was the case, something to do with the way I had created the tables in the first place.

Anyway, all I needed to do was use MySQL Workbench to alter the tables which did not have AI ids and add the AI property. (I had to delete and re-create some foreign keys as part of this process as well).



来源:https://stackoverflow.com/questions/11029290/persistenceexception-error-executing-dml-bindlog-errorfield-id-doesnt-hav

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!