你不當心使用了數據庫的關鍵字 那麼就會報這個錯誤 「SQL Error: 1064, SQLState: 42000錯誤」數據庫
解決方法有三種:this
1、將表名或字段名用方括號([])括起來。code
xml配置:xml
<property name="desc" type="string" > <column name="[DESC]" length="255" not-null="true" /> </property>
註解:get
@Column(name = "[DESC]", nullable = false) public String getDesc() { return this.desc; }
2、將表名或字段名用兩個重音符號(`)括起來 重音符號鍵便是鍵盤上「1」鍵左邊的、「Tab」鍵上邊的那個鍵。此符號亦被稱爲「反向引號」。string
xml配置:配置
<property name="desc" type="string" > <column name="`DESC`" length="255" not-null="true" /> </property>
註解:方法
@Column(name = "`DESC`", nullable = false) public String getDesc() { return this.desc; }
3、將表名或字段名用雙引號(")括起來 xml配置:數據
<property name="desc" type="string" > <column name='"DESC"' length="255" not-null="true" /> </property>
註解:鍵盤
@Column(name = "\"DESC\"", nullable = false) public String getDesc() { return this.desc; }