欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Spring JPA 增加字段執(zhí)行異常問題及解決

 更新時(shí)間:2022年06月10日 16:57:07   作者:hgc0907  
這篇文章主要介紹了Spring JPA 增加字段執(zhí)行異常問題及解決,具有很好的參考價(jià)值,

Spring JPA 增加字段執(zhí)行異常

用Spring jpa Entity里面增加了幾個(gè)字段,但啟動(dòng)報(bào)錯(cuò),提示

column Unable to execute schema management to JDBC target:

alter table qps_dictionary add column create_by varchar(10) ?'創(chuàng)建者'; 

這條語句出錯(cuò)。

復(fù)制語句到客戶端執(zhí)行,mysql果然提示語法錯(cuò)誤,后來修改實(shí)體信息增加comment:在創(chuàng)建者簽名增加comment即可

@Column(columnDefinition = "varchar(10) comment '創(chuàng)建者'",name = "create_by")

JPA自增字段自動(dòng)添加報(bào)錯(cuò)“error performing isolated work”

在使用Jpa對(duì)數(shù)據(jù)庫進(jìn)行操作是時(shí),設(shè)置的自增字段在進(jìn)行插入操作時(shí)也必須set,否則會(huì)報(bào)錯(cuò)添加失敗。

使用@GeneratedValue 注解能實(shí)現(xiàn)自增字段自動(dòng)添加。

但是使用 @GeneratedValue 會(huì)報(bào)錯(cuò) “error performing isolated work

@Id
@GeneratedValue
private Integer newsId;

------錯(cuò)誤分割線-------

正確做法是使用  

@GeneratedValue(strategy = GenerationType.IDENTITY)
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer newsId;

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論