Importing hibernate configuration file into Spring applicationContext

Posted by Himanshu Yadav on Stack Overflow See other posts from Stack Overflow or by Himanshu Yadav
Published on 2012-05-30T15:51:32Z Indexed on 2012/09/21 9:38 UTC
Read the original article Hit count: 270

Filed under:
|
|

I am trying to integrate Hibernate 3 with Spring 3.1.0. The problem is that application is not able to find mapping file which declared in hibernate.cfg.xml file. Initially hibernate configuration has datasource configuration, hibernate properties and mapping hbm.xml files. Master hibernate.cfg.xml file exist in src folder. this is how Master file looks:

<hibernate-configuration>
    <session-factory>
        <!-- Mappings -->
        <mapping resource="com/test/class1.hbm.xml"/>
        <mapping resource="/class2.hbm.xml"/>
        <mapping resource="com/test/class3.hbm.xml"/>
        <mapping resource="com/test/class4.hbm.xml"/>
        <mapping resource="com/test/class5.hbm.xml"/>

Spring config is:

<bean id="sessionFactoryEditSolution" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="data1"/>
        <property name="mappingResources">
            <list>
                <value>/master.hibernate.cfg.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
                <prop key="hibernate.cache.use_second_level_cache">true</prop>

            </props>
        </property>
    </bean>

© Stack Overflow or respective owner

Related posts about java

Related posts about spring