PersistenceException:执行DML bindLog []时出错,错误[字段'id'没有默认值] [英] PersistenceException: ERROR executing DML bindLog[] error[Field 'id' doesn't have a default value]

查看:211
本文介绍了PersistenceException:执行DML bindLog []时出错,错误[字段'id'没有默认值]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用MySQL和ebeans保存任务.当我应用脚本时,出现此错误:

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]]

在将MySQL用作数据库之前,它可以与内存和文件系统中的H2 DB一起正常工作.

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

如何解决此错误?

推荐答案

只是遇到了相同的错误. 在您的id字段和演化脚本的约束中添加AUTO_INCREMENT.就像这样

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

);

现在可以使用

如果您使用@Id注释模型中的字段"id",则应自动添加AUTO_INCREMENT和约束

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

这篇关于PersistenceException:执行DML bindLog []时出错,错误[字段'id'没有默认值]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆