1

I have a problem that slow down my development in general. The deployment of my webapplication is slow.

The main problem come from the creation of te entityManagerFactory which take like 15sec (when the deployment on the server only take 1 second):

entityManagerFactory = Persistence.createEntityManagerFactory("calamar");

Is there a way to reduce it?

Logs :

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.
Antoine Grenard
  • 1,712
  • 3
  • 21
  • 41
  • Depends on what the actual problem is. You can't solve problems until you know where the problem is. Might be that it takes a while to connect to the database for example. Might be that the schema is huge and you have auto-schema generation turned on. Might be lots of things. – Gimby Sep 09 '16 at 07:18
  • I think it come from the initiation of the dialect PostgreSQL which take 9 sec. (I've posted the logs) – Antoine Grenard Sep 09 '16 at 07:36
  • Possibly that is the time spent registering entities. you might get more information if you set your logging for org.hibernate to debug or even trace. – Gimby Sep 09 '16 at 07:42
  • So i've search a little about the log line that was taking time and i've found that when i had this property it take only 2 sec. But i can't find any documentation on it ... Do you know where can i found some ? – Antoine Grenard Sep 09 '16 at 08:01

1 Answers1

3

I've found a way to do it adding this property :

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

It is working but i don't know where to find documentation about what is this property exactly doing. If someone could help ?

(Hibernate Slow to Acquire Postgres Connection)

Community
  • 1
  • 1
Antoine Grenard
  • 1,712
  • 3
  • 21
  • 41