我的 Entity 类有一个如下所示的列:
@Entity
@Table(name = "addons")
public class AddonsEntity {
private int id;
private String name;
private BigDecimal price;
private int addonGroupId;
private int order;
private AddonGroupsEntity addonGroupsByAddonGroupId;
@Id
@Column(name = "id", nullable = false, insertable = true, updatable = true)
@GeneratedValue(generator="increment") @GenericGenerator(name="increment", strategy="increment")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
这转换为sql,如:
创建表插件(id整数不为空,....);
由于 mysql 中没有整数,因此会引发错误。
版本:
'org.hibernate', name: 'hibernate-core', version: '4.3.10.Final'
'org.hibernate', name: 'hibernate-c3p0', version: '4.3.10.Final'
'mysql', name: 'mysql-connector-java', version: '5.1.35'
Mysql Server version: 5.6.25 Homebrew
Java 1.8
SQL翻译:
create table addons (
id integer not null,
addon_group_id integer not null,
name varchar(200) not null,
order integer not null,
price decimal(2,0) not null,
addonGroupsByAddonGroupId_id integer not null,
primary key (id)
)
错误:
2015-07-21 01:26:13 [] ERROR [Scanner-1] o.h.t.h.SchemaExport [SchemaExport.java:426] HHH000389: Unsuccessful: create table addons (id integer not null, addon_group_id integer not null, name varchar(200) not null, order integer not null, price decimal(2,0) not null, addonGroupsByAddonGroupId_id integer not null, primary key (id))
2015-07-21 01:26:13 [] ERROR [Scanner-1] o.h.t.h.SchemaExport [SchemaExport.java:427] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order integer not null,price decimal(2,0) not null,addonGroups' at line 5