Spring Hibernate is not able to load the hibernate.cfg.xml from multiple components into the main project

Dev Environment Java 8
Spring 4.0.0
Hibernate 3.6.9.Final
XML Based Configurations and Entity Mappings

abstractSessionFactory Initialization from parent component

<property name="dataSource" ref="dataSource" />

    <property name="configurationClass" value="org.hibernate.cfg.Configuration" /> 
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
            <prop key="hibernate.show_sql">${hibernate.showSql}</prop>
            <prop key="hibernate.default_batch_fetch_size">32</prop>
            <prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
            <prop key="hibernate.order_updates">true</prop>
            <prop key="hibernate.jdbc.batch_size">32</prop>

            <!-- enable caching -->
            <prop key="hibernate.cache.use_second_level_cache">${hibernate.useSecondLevelCache}</prop>
            <prop key="hibernate.cache.provider_class">${hibernate.cacheProviderClass}</prop>
            <prop key="hibernate.cache.use_minimal_puts">${hibernate.useMinimalPuts}</prop>
            <prop key="hibernate.cache.use_query_cache">${hibernate.useQueryCache}</prop>

            <prop key="hibernate.default_schema">dbo</prop>
        </props>
        
    </property>
       
</bean>`

Hibernate.cfg.xml path in main-web Project resources/hibernate.cfg.xml

hibernate.cfg.xml in main project

Hibernate.cfg.xml path in components/jar (Same like the main-web project) resources/META-INF/spring-hibernate/hibernate.cfg.xml

hibernate.cfg.xml in component/jar

Here the component’s hibernate.cfg.xml is not loading and the entities exist in that file is not returning any result from the DB. But if I use the packagesToScan property then every things works fine.

Problem: only the hibernate.cfg.xml from main-web project is loading, the hibernate.cfg.xml files from the components/jar are not loading. But if the “packagesToScan” property is used then the hibernate mappings from components / jars are also loaded. Is there any way spring can load the hibernate.cfg.xml file dynamically instead of one by one?

Session Factory Initialization in the main

<bean id="sessionFactory"  parent="abstractSessionFactory">     
      <property name="configLocations">
        <list value-type = "org.springframework.core.io.Resource">
              <value>classpath:hibernate.cfg.xml</value> 
            
        </list>
    </property>  
</bean>

See Maintenance Policy - Hibernate. If you want community support, upgrade to the latest Hibernate ORM version.