Java @hibernate中的GeneratedValue(策略=标识)在部署时不生成关系(表)
我的代码中包含以下内容:Java @hibernate中的GeneratedValue(策略=标识)在部署时不生成关系(表),java,mysql,hibernate,Java,Mysql,Hibernate,我的代码中包含以下内容: @Id @GeneratedValue(strategy = IDENTITY) @Column(name = "id", unique = true, nullable = false) private Long id; 而且,我注意到当我有@GeneratedValue时,它不会生成我的MySql表,但是如果没有注释,它会生成相应的表 我应该检查哪些关键点?这是非常棘手的,因为您可能认为您已经正确定义了hibernate的所有属性,并且添加了@GeneratedV
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private Long id;
而且,我注意到当我有@GeneratedValue时,它不会生成我的MySql表,但是如果没有注释,它会生成相应的表
我应该检查哪些关键点?这是非常棘手的,因为您可能认为您已经正确定义了hibernate的所有属性,并且添加了@GeneratedValue注释,导致了SQL错误。然而,我能够通过更仔细地研究hibernate属性来解决这个问题。在hibernate配置中特别查找以下属性。 属性名称=hibernateProperties>
hibernate.dialect=${hibernate.dialect}
hibernate.hbm2ddl.auto=create
对于hibernate.dialogue->您应该有org.hibernate.dialogue.mysql5innodbdialogue
但您可能会看到,它还为MySQL数据库中的->org.hibernate.dialent.sqlserverdialent生成了表,这使您得出结论,您已经正确设置了hibernate属性。
如果任何元数据注释产生语法错误,我强烈建议您检查hibernate属性
谢谢