SpringJPA增加字段执行异常问题及解决,
分享于 点击 10653 次 点评:45
SpringJPA增加字段执行异常问题及解决,
目录
- Spring JPA 增加字段执行异常
- JPA自增字段自动添加报错“error performing isolated work”
- 正确做法是使用
Spring JPA 增加字段执行异常
用Spring jpa Entity里面增加了几个字段,但启动报错,提示
column Unable to execute schema management to JDBC target:
alter table qps_dictionary add column create_by varchar(10) '创建者';
这条语句出错。
复制语句到客户端执行,mysql果然提示语法错误,后来修改实体信息增加comment:在创建者签名增加comment即可
@Column(columnDefinition = "varchar(10) comment '创建者'",name = "create_by")
JPA自增字段自动添加报错“error performing isolated work”
在使用Jpa对数据库进行操作是时,设置的自增字段在进行插入操作时也必须set,否则会报错添加失败。
使用@GeneratedValue 注解能实现自增字段自动添加。
但是使用 @GeneratedValue 会报错 “error performing isolated work
@Id @GeneratedValue private Integer newsId;
------错误分割线-------
正确做法是使用
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer newsId;
以上为个人经验,希望能给大家一个参考,也希望大家多多支持3672js教程。
您可能感兴趣的文章:- 解决springboot的JPA在Mysql8新增记录失败的问题
- 解决springjpa的局部更新字段问题
- Spring boot Jpa添加对象字段使用数据库默认值操作
用户点评