PersistenceException: ERROR executing DML bindLog[

2019-07-20 10:25发布

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?

2条回答
可以哭但决不认输i
2楼-- · 2019-07-20 11:09

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).

查看更多
小情绪 Triste *
3楼-- · 2019-07-20 11:15

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

查看更多
登录 后发表回答