多对一单向关联: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 搞定