在使用postgresql驱动程序的JPA项目中,表是自动生成的。当我切换到h2数据库驱动程序时,出现错误,找不到表。我假设这些表没有生成。
Postgresql配置
<persistence-unit name="postgresql" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>...</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://127.0.0.1/example"/>
<property name="javax.persistence.jdbc.password" value="example"/>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
<property name="javax.persistence.jdbc.user" value="example"/>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
</properties>
</persistence-unit>
h2 config
<persistence-unit name="OntoJobTestDB" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>...</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:test" />
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
</properties>
</persistence-unit>
答案 0 :(得分:2)
@Converter
注释导致的早期错误(postgresql特定)阻止了表的创建。
我的建议是始终仔细检查调试输出。