多对一Hibernate自动建表问题

来源:互联网 发布:魔兽争霸3mac原生版 编辑:程序博客网 时间:2024/05/29 04:36

多对一单向关联:User   Group

Hibernate建表不成功  报错  :hibernate 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 'Group (id integer not null auto_increment,


原因:配置默认创建的是group表。这在mysql中应该是保留字。换个表名就OK了


做法:

@Entity
@Table(name="t_group")
public class Group 
{
private int id;

private String name;


@Id
@GeneratedValue
public int getId() {
return id;
}


public void setId(int id) {
this.id = id;
}


easy  搞定