簡體   English   中英

JPA CreateEntityManagerFactory()方法掛起

[英]JPA CreateEntityManagerFactory() method hangs

我以下列方式使用此方法

EntityManagerFactory emftemp = Persistence.createEntityManagerFactory("XYZ");

並且我的persistence.xml具有此單元的以下條目

<persistence-unit name="XYZ" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
        <property name="hibernate.show_sql" value="false"/>
        <property name="hibernate.hbm2ddl.auto" value="validate"/>
        <property name="hibernate.query.substitutions" value="true=1, false=0"/>
        <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver"/>
        <property name="hibernate.connection.url" value="jdbc:oracle:thin:@aesop-db.corp.nlg1.com:1521:TLCSDEV4"/>
        <property name="hibernate.connection.username" value="abcd"/>
        <property name="hibernate.connection.password" value="abcd"/>
        <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9iDialect"/>
    <property name="hibernate.connection.timeout" value="120"/>
    <property name="hibernate.connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider" />
    <property name="hibernate.c3p0.min_size" value="2"/>
    <property name="hibernate.c3p0.max_size" value="2"/>
    <property name="hibernate.c3p0.idle_test_period" value="60"/>
    </properties>
</persistence-unit>

這是一個Java應用程序,我正在使用hibernate3.jar,我使用的是ejb3-persistence.jar和JDK1.5。

問題是每次我運行應用程序時,它都會掛起這個調用。 它沒有拋出任何異常或錯誤。 它只是掛在那一點上。

任何人都可以幫助確定它為什么不向前發展?

兩個想法:

  1. 當有什么東西掛起時,通常會出現IO /網絡問題。 因此,請嘗試確保數據庫確實存在,並且您可以從計算機連接到該數據庫。
  2. 這可能是Persistence.createEntityManagerFactory需要很長時間的重復

我對Oracle 11g數據庫遇到了同樣的問題,只定義了三個實體但是數據庫很大。 從persistence.xml中注釋掉以下行后,問題得以解決。

<property name="hibernate.hbm2ddl.auto" value="update"/>

暫無
暫無

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

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