Performance Issue after upgrading to Hibernate 5.0.2 - Tomcat Server start-up time increased

Description

After upgrading Hibernate version from 4.3.9.Final to 5.0.2.Final, Tomcat Server start-up time has increased.

After debugging, I realized that hibernate takes too much time in adding mapping locations (*.hbm.xml files) in its metadata sources.

I have added mapping location in session factory using following code, and in my project there are around 1000 hbm.xml files.

<bean id="baseSessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">

<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.jdbc.fetch_size">300</prop>
<prop key="net.sf.ehcache.configurationResourceName">/ehcache.xml</prop>
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory</prop>
</props>
</property>

<property name="dataSource" ref="dataSource" />
<property name="mappingLocations">
<list>
<value>classpath*:com///.hbm.xml</value>
</list>
</property>
</bean>

While starting tomcat server, I debugged and fournd that in method

org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet

following for loop takes too much time to add all mapping locations in metadata sources object of configuration class.

if (this.mappingLocations != null) {
// Register given Hibernate mapping definitions, contained in resource files.
for (Resource resource : this.mappingLocations) {
sfb.addInputStream(resource.getInputStream());
}
}

Issue:- Tomcat Server Time increased from appx. 3 minutes to 8 minutes after upgrading to Hibernate-5.0.2.Final.

Environment

None

Status

Assignee

Unassigned

Reporter

Nirav Patel

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure