Hibernate 5 is taking very long time in CRUD operation with Microsoft SQL Server database

Good Day!

I migrated hibernate from 4.1.7.Final to 5.1.10.Final. But I am facing an issue with CRUD operation in transnational context. Its taking very long time while the same is working fine in the older version. Is there any configuration I missed in Hibernate 5 that is causing this issue. Appreciate your assistance!

What exactly takes a very long time? It’s not clear what the problem is all about.

Hi Vlad,

When we are going to save or update data, its taking so much time. I enabled the logger in debug mode and found lots of select queries is getting executed that is taking longer time to complete the transaction. But in hibernate 4.1.7 the same code is working absolutely fine. So I am not sure what is causing issue with hibernate 5.

Hi Vlad,

Plz find the below config file detail:

<?xml version="1.0" encoding="UTF-8"?>



java:/jboss/datasources/CollateralDS

























You need to add the code that you are executing and the generated SQL statements so that we can better understand what you are doing.

Thanks Vlad. I identified the issue. I am working with the latest version hibernate-core-5.3.2.Final. But I am getting below issue and I suspect it’s just because of the missing hibernate-infinispan-5.3.2.Final.jar file. Could you plz assist to get this jar file. Its not available on Maven repository as well.

15:19:28,868 WARN [org.jboss.modules] (MSC service thread 1-3) Failed to define class org.hibernate.cache.infinispan.collection.CollectionRegionImpl in Module "org.hibernate.infinispan" from local module loader @7fe8ea47 (finder: local module finder @226a82c4 (roots: c:\Software\JBossEAP\jboss-eap-7.1.0\jboss-eap-7.1\modules,c:\Software\JBossEAP\jboss-eap-7.1.0\jboss-eap-7.1\modules\system\layers\base)): java.lang.NoClassDefFoundError: Failed to link org/hibernate/cache/infinispan/collection/CollectionRegionImpl (Module "org.hibernate.infinispan" from local module loader @7fe8ea47 (finder: local module finder @226a82c4 (roots: c:\Software\JBossEAP\jboss-eap-7.1.0\jboss-eap-7.1\modules,c:\Software\JBossEAP\jboss-eap-7.1.0\jboss-eap-7.1\modules\system\layers\base))): org/hibernate/cache/spi/CollectionRegion

1 Like

The hibernate-infinispan modules was moved to Infinispan, as well as the documentation. which explains the dependency to use:

<dependency>
   <groupId>org.infinispan</groupId>
   <artifactId>infinispan-hibernate-cache-v53</artifactId>
   <version>${version.infinispan}</version> <!-- 9.2.2.Final or higher -->
</dependency>

Hi Vlad,
As advised I am trying with infinispan-hibernate-cache-v53-9.2.5.Final.jar file in JBoss EAP 7.1 but getting below exception. Could you plz advise on this?

16:12:33,783 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 75) MSC000001: Failed to start service jboss.persistenceunit."casdm.ear/adapter.jar#integration".__FIRST_PHASE__: org.jboss.msc.service.StartException in service jboss.persistenceunit."casdm.ear/adapter.jar#integration".__FIRST_PHASE__: java.lang.NoClassDefFoundError: Failed to link org/infinispan/hibernate/cache/v53/InfinispanRegionFactory (Module "org.hibernate.infinispan" from local module loader @7fe8ea47 (finder: local module finder @226a82c4 (roots: c:\Software\JBossEAP\jboss-eap-7.1.0\jboss-eap-7.1\modules,c:\Software\JBossEAP\jboss-eap-7.1.0\jboss-eap-7.1\modules\system\layers\base))): org/infinispan/hibernate/cache/commons/TimeSource
	at org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1$1.run(PhaseOnePersistenceUnitServiceImpl.java:128) [wildfly-jpa-7.1.0.GA-redhat-11.jar:7.1.0.GA-redhat-11]
	at org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1$1.run(PhaseOnePersistenceUnitServiceImpl.java:104) [wildfly-jpa-7.1.0.GA-redhat-11.jar:7.1.0.GA-redhat-11]
	at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:640) [wildfly-elytron-1.1.7.Final-redhat-1.jar:1.1.7.Final-redhat-1]
	at org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1.run(PhaseOnePersistenceUnitServiceImpl.java:137) [wildfly-jpa-7.1.0.GA-redhat-11.jar:7.1.0.GA-redhat-11]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [rt.jar:1.8.0_171]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [rt.jar:1.8.0_171]
	at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_171]
	at org.jboss.threads.JBossThread.run(JBossThread.java:320) [jboss-threads-2.2.1.Final-redhat-1.jar:2.2.1.Final-redhat-1]
Caused by: java.lang.NoClassDefFoundError: Failed to link org/infinispan/hibernate/cache/v53/InfinispanRegionFactory (Module "org.hibernate.infinispan" from local module loader @7fe8ea47 (finder: local module finder @226a82c4 (roots: c:\Software\JBossEAP\jboss-eap-7.1.0\jboss-eap-7.1\modules,c:\Software\JBossEAP\jboss-eap-7.1.0\jboss-eap-7.1\modules\system\layers\base))): org/infinispan/hibernate/cache/commons/TimeSource
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.8.0_171]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [rt.jar:1.8.0_171]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [rt.jar:1.8.0_171]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423) [rt.jar:1.8.0_171]
	at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446) [jboss-modules.jar:1.6.0.Final-redhat-1]
	at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274) [jboss-modules.jar:1.6.0.Final-redhat-1]
	at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:77) [jboss-modules.jar:1.6.0.Final-redhat-1]
	at org.jboss.modules.Module.loadModuleClass(Module.java:713) [jboss-modules.jar:1.6.0.Final-redhat-1]
	at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.6.0.Final-redhat-1]
	at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:412) [jboss-modules.jar:1.6.0.Final-redhat-1]
	at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:400) [jboss-modules.jar:1.6.0.Final-redhat-1]
	at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116) [jboss-modules.jar:1.6.0.Final-redhat-1]
	at org.infinispan.hibernate.cache.v53.StrategyRegistrationProviderImpl.getStrategyRegistrations(StrategyRegistrationProviderImpl.java:30)
	at org.hibernate.boot.registry.selector.internal.StrategySelectorBuilder.buildSelector(StrategySelectorBuilder.java:173)
	at org.hibernate.boot.registry.BootstrapServiceRegistryBuilder.build(BootstrapServiceRegistryBuilder.java:232)
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.buildBootstrapServiceRegistry(EntityManagerFactoryBuilderImpl.java:455)
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:199)
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:167)
	at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:32)
	at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:89)
	at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.<init>(TwoPhaseBootstrapImpl.java:39)
	at org.jboss.as.jpa.hibernate5.HibernatePersistenceProviderAdaptor.getBootstrap(HibernatePersistenceProviderAdaptor.java:199)
	at org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl.createContainerEntityManagerFactoryBuilder(PhaseOnePersistenceUnitServiceImpl.java:254) [wildfly-jpa-7.1.0.GA-redhat-11.jar:7.1.0.GA-redhat-11]
	at org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl.access$900(PhaseOnePersistenceUnitServiceImpl.java:59) [wildfly-jpa-7.1.0.GA-redhat-11.jar:7.1.0.GA-redhat-11]
	at org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1$1.run(PhaseOnePersistenceUnitServiceImpl.java:125) [wildfly-jpa-7.1.0.GA-redhat-11.jar:7.1.0.GA-redhat-11]
	... 7 more

Better ask the question on the JBoss or Wildfly forum as they surely can better help you with this kind of problems.

Thanks Vlad…much appreciated.

1 Like

Have you tried to update your connector? I had a similar problem some time ago and it was solved using an open source connector, not Ms driver.

The Microsoft SQL Server driver is the best one nowadays, and it’s fully open source. JTDS used to be an alternative a very long time ago, but not anymore.

1 Like