我正在使用hibernate-maven-plugin引导数据库,该数据库使用在执行它的maven模块中扫描的模型。
不幸的是,它在休眠抛出以下内容时停止:
org.hibernate.tool.schema.spi.SchemaManagementException: SQL strings added more than once for: reference_data_source.UK-UK_9ec6wdvyj3mjagiptcnrq2txv
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.checkExportIdentifier(SchemaCreatorImpl.java:299)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:255)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:128)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:199)
Run Code Online (Sandbox Code Playgroud)
因此,我有两个持久性单元,并且两个表中都存在一些表。Hibernate似乎将其解释为相同的表,因此,当它尝试存储相同的索引时,对于另一个模式,它无法认为它是重复的。他们的代码可以在这里找到。
我不确定如何解决这个问题,无论如何配置休眠hbm2ddl来跟踪这些不同的持久性单元?
这是hibernate-maven-plugin的配置:
<plugin>
<groupId>de.juplo</groupId>
<artifactId>hibernate-maven-plugin</artifactId>
<version>2.0.0</version>
<configuration>
<detail>true</detail>
<persistenceUnit>mainPersistenceUnit</persistenceUnit>
<driver>com.mysql.jdbc.Driver</driver>
<dialect>org.hibernate.dialect.MySQL5Dialect</dialect>
<force>true</force>
<url><![CDATA[jdbc:mysql://localhost/auto_bootstrap_schema]]></url>
<username>user</username>
<password>pass</password>
</configuration>
<executions>
<execution>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-connector-java.version}</version>
</dependency>
</dependencies>
</plugin>
Run Code Online (Sandbox Code Playgroud)
小智 7
我有同样的问题。在我的情况下,原因是我有三个以相同的前缀名称开头的实体,并且每个实体都具有一个更专业的关系:
Person
PersonCard
PersonCardLayout
Run Code Online (Sandbox Code Playgroud)
将模型重命名为此解决了我的问题:
Person
Card
Layout
Run Code Online (Sandbox Code Playgroud)
这似乎是Hibernate中的错误。