entityManagerFactory启动缓慢

时间:2016-09-09 07:13:45

标签: hibernate java-ee hibernate-entitymanager

我遇到的问题一般会减慢我的发展速度。我的Web应用程序的部署很慢。

主要问题来自te entityManagerFactory的创建,花费了15秒(当服务器上的部署只需要1秒时):

entityManagerFactory = Persistence.createEntityManagerFactory("calamar");

有没有办法减少它?

日志:

2016-09-09 09:10:01,260 [INFO ] (LogHelper.java:logPersistenceUnitInformation:31) HHH000204: Processing PersistenceUnitInfo [
    name: calamar
    ...]
2016-09-09 09:10:01,454 [INFO ] (Version.java:logVersion:37) HHH000412: Hibernate Core {5.1.0.Final}
2016-09-09 09:10:01,456 [INFO ] (Environment.java:<clinit>:213) HHH000206: hibernate.properties not found
2016-09-09 09:10:01,459 [INFO ] (Environment.java:buildBytecodeProvider:317) HHH000021: Bytecode provider name : javassist
2016-09-09 09:10:01,648 [INFO ] (JavaReflectionManager.java:<clinit>:66) HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2016-09-09 09:10:02,000 [WARN ] (DriverManagerConnectionProviderImpl.java:configure:71) HHH10001002: Using Hibernate built-in connection pool (not for production use!)
2016-09-09 09:10:02,007 [INFO ] (DriverManagerConnectionProviderImpl.java:buildCreator:127) HHH10001005: using driver [org.postgresql.Driver] at URL [url]
2016-09-09 09:10:02,008 [INFO ] (DriverManagerConnectionProviderImpl.java:buildCreator:136) HHH10001001: Connection properties: {user=user, password=****}
2016-09-09 09:10:02,008 [INFO ] (DriverManagerConnectionProviderImpl.java:buildCreator:141) HHH10001003: Autocommit mode: false
2016-09-09 09:10:02,016 [INFO ] (PooledConnections.java:<init>:39) HHH000115: Hibernate connection pool size: 20 (min=1)
2016-09-09 09:10:02,197 [INFO ] (Dialect.java:<init>:156) HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2016-09-09 09:10:11,359 [INFO ] (LobCreatorBuilderImpl.java:useContextualLobCreation:124) HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
2016-09-09 09:10:11,378 [INFO ] (BasicTypeRegistry.java:register:138) HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@ede237b
2016-09-09 09:10:11,919 [WARN ] (SequenceGenerator.java:configure:87) HHH90000014: Found use of deprecated [org.hibernate.id.SequenceHiLoGenerator] sequence-based id generator; use org.hibernate.id.enhanced.SequenceStyleGenerator instead.  See Hibernate Domain Model Mapping Guide for details.
2016-09-09 09:10:11,925 [WARN ] (SequenceGenerator.java:configure:87) HHH90000014: Found use of deprecated [org.hibernate.id.SequenceHiLoGenerator] sequence-based id generator; use org.hibernate.id.enhanced.SequenceStyleGenerator instead.  See Hibernate Domain Model Mapping Guide for details.
2016-09-09 09:10:11,925 [WARN ] (SequenceGenerator.java:configure:87) HHH90000014: Found use of deprecated [org.hibernate.id.SequenceHiLoGenerator] sequence-based id generator; use org.hibernate.id.enhanced.SequenceStyleGenerator instead.  See Hibernate Domain Model Mapping Guide for details.

1 个答案:

答案 0 :(得分:1)

我找到了添加此属性的方法:

<property name="hibernate.temp.use_jdbc_metadata_defaults" value="false" />

它正在运作,但我不知道在哪里可以找到有关该属性正在做什么的文档。如果有人可以帮忙?

Hibernate Slow to Acquire Postgres Connection