软件编程
位置:首页>> 软件编程>> java编程>> Spring JPA 增加字段执行异常问题及解决

Spring JPA 增加字段执行异常问题及解决

作者:hgc0907  发布时间:2023-06-25 23:55:58 

标签:Spring,JPA,字段,执行异常

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;

来源:https://blog.csdn.net/hgc0907/article/details/81100542

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com