我有一個項目,我已經使用jpa +休眠。 我有一個persistence.xml文件,並希望它自動創建數據庫中的表。我已經正確指定了所有的屬性。 在日誌中顯示所有的sql語句,但仍然在數據庫中沒有表。 有沒有人有這個問題的解決方案 我已經搜索了幾乎所有與我的問題有關的鏈接,但沒有任何工作。休眠與jpa不會自動創建表中wildfly
這裏是我的persistence.xml
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="pl4sms-persistence" >
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.ecomm.pl4sms.persistence.entities.SampleBatch</class>
<class>com.ecomm.pl4sms.persistence.entities.SampleMessage</class>
<properties>
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
<property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432/samplejpa"/>
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.connection.password" value="root"/>
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="create" />
</properties>
</persistence-unit>
</persistence>
這就是我得到的控制檯
16:35:48881 INFO [org.hibernate.annotations.common.Version(Server服務線程池 - - 23)HCANN000001:Hibernate Commons Annotations {4.0.4.Final} 16:35:49,069信息[org.hibernate.dialect.Dialect](ServerService線程池 - 23)HHH000400:使用方言:org.hibernate.dialect。 H2Dialect 16:35:49,084 WARN [org.hibernate.dialect.H2Dialect](ServerService線程池 - 23)HHH000431:無法確定H2數據庫e版本,某些功能可能不起作用 16:35:49,225信息[org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory](ServerService線程池 - 23)HHH000397:使用ASTQueryTranslatorFactory 16:35:49,537 INFO [ hibernate.tool.hbm2ddl.SchemaExport](服務器服務線程池 - 23)HHH000227:運行hbm2ddl架構導出
您使用的GUI工具pgAdmin的Postgres的 – silentprogrammer 2015-02-05 13:03:12
是的,我使用的pgAdmin創建數據庫 – user3588548 2015-02-05 13:07:47
那奇怪,因爲創建查詢在控制檯中顯示你檢查的pgAdmin'PostgreSql-> samplejpa-> Schemas->公共 - > Tables'的表如果在控制檯中顯示任何問題。 – silentprogrammer 2015-02-05 14:11:31