多對一單向關聯: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 搞定