好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

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

Spring JPA 增加字段执行异常

用Spring jpa Entity里面增加了几个字段,但启动报错,提示

column Unable to execute schema management to JDBC target:

?

1

alter table qps_dictionary add column create_by varchar( 10 )   '创建者' ;

这条语句出错。

复制语句到客户端执行,mysql果然提示语法错误,后来修改实体信息增加comment:在创建者签名增加comment即可

?

1

@Column (columnDefinition = "varchar(10) comment '创建者'" ,name = "create_by" )

JPA自增字段自动添加报错[error performing isolated work]

在使用Jpa对数据库进行操作是时,设置的自增字段在进行插入操作时也必须set,否则会报错添加失败。

使用@GeneratedValue 注解能实现自增字段自动添加。

但是使用 @GeneratedValue 会报错 [error performing isolated work

?

1

2

3

@Id

@GeneratedValue

private Integer newsId;

------错误分割线-------

正确做法是使用  

?

1

@GeneratedValue (strategy = GenerationType.IDENTITY)

?

1

2

3

@Id

@GeneratedValue (strategy = GenerationType.IDENTITY)

private Integer newsId;

以上为个人经验,希望能给大家一个参考,也希望大家多多支持。

原文链接:https://blog.csdn.net/hgc0907/article/details/81100542

查看更多关于Spring JPA 增加字段执行异常问题及解决的详细内容...

  阅读:22次