簡體   English   中英

使用jpa進行Hibernate不會在wildfly中自動創建表

[英]Hibernate with jpa not creating tables automatically in wildfly

我正在進行一個項目,其中我使用了jpa + hibernate。 我有一個persistence.xml文件,並希望它自動在數據庫中創建表。我已正確指定了所有屬性。 在日志中它顯示了所有sql語句,但仍然在數據庫中沒有表。 有沒有人有這個問題的解決方案我搜索了幾乎所有與我的問題相關的鏈接但沒有任何效果。

這是我的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:48,881 INFO [org.hibernate.annotations.common.Version](ServerService線程池 - 23)HCANN000001:Hibernate Commons Annotations {4.0.4.Final} 16:35:49,069 INFO [org.hibernate.dialect。方言](ServerService線程池 - 23)HHH000400:使用方言:org.hibernate.dialect.H2Dialect 16:35:49,084 WARN [org.hibernate.dialect.H2Dialect](ServerService線程池 - 23)HHH000431:無法確定H2數據庫版本,某些功能可能無效16:35:49,225 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory](ServerService線程池 - 23)HHH000397:使用ASTQueryTranslatorFactory 16:35:49,537 INFO [org.hibernate .tool.hbm2ddl.SchemaExport](ServerService線程池 - 23)HHH000227:運行hbm2ddl模式導出

日志清楚地表明已創建表。 如果有異常或類似的東西,您需要在問題上發布。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM