Java 不成功:更改表格添加约束:表格不';不存在于创建上

Java 不成功:更改表格添加约束:表格不';不存在于创建上,java,mysql,hibernate,jpa,Java,Mysql,Hibernate,Jpa,我对一个女人有奇怪的行为: 实体1: @OneToMany(fetch = FetchType.LAZY, mappedBy = "entity1") private Set<Deal> deals; 我还有: properties.setProperty("hibernate.hbm2ddl.auto", "create"); 启动时会出现以下错误: ERROR: org.hibernate.tool.hbm2ddl.SchemaExport - HHH000389: Unsu

我对一个女人有奇怪的行为:

实体1:

@OneToMany(fetch = FetchType.LAZY, mappedBy = "entity1")
private Set<Deal> deals;
我还有:

properties.setProperty("hibernate.hbm2ddl.auto", "create");
启动时会出现以下错误:

ERROR: org.hibernate.tool.hbm2ddl.SchemaExport - HHH000389: Unsuccessful: alter table deal add constraint FK_d17qqf8ra0ibdsnngbp465qvs foreign key (entity1_id) references entity1 (entity1_id)
ERROR: org.hibernate.tool.hbm2ddl.SchemaExport - Table 'test.deal' doesn't exist

我尝试从数据库中删除所有表,所有表都已成功创建(我在其他实体中有这种类型的关系,这些表也已创建),除了这一个。我做错了什么?谢谢。

我终于找到了问题所在。 为了命名我的字段,我使用了MySQL关键字:To、from、show。 因此,Hibernate生成的SQL创建请求对于MySQL来说完全是胡言乱语,唯一的迹象是服务器发出的语法错误的消息。
我是通过逐个删除字段并一步一步地重新启动来找到它的。

Deal
(和
Entity1
)类是用
@Entity
注释的?已经存在同名的表了吗?然后尝试删除它们并运行程序,或者尝试使用
create drop
,而不是
create drop
。@redflar3如我在问题中所述,我尝试删除所有表。Create drop没有任何区别。您能尝试将其更改为
@JoinColumn(name=“entity1_id2”)
@redflar3我尝试过,但没有帮助,我从字段获得了一个
。谢谢你的提示!
ERROR: org.hibernate.tool.hbm2ddl.SchemaExport - HHH000389: Unsuccessful: alter table deal add constraint FK_d17qqf8ra0ibdsnngbp465qvs foreign key (entity1_id) references entity1 (entity1_id)
ERROR: org.hibernate.tool.hbm2ddl.SchemaExport - Table 'test.deal' doesn't exist