当前位置: 动力学知识库 > 问答 > 编程问答 >

Spring and Hibernate: Loading cfg.xml into application context

问题描述:

datasource.hibernate.cfg.xml has hiberanteProperties and all the mapping resources.

But right now I have to define mapping resources and properties in applicationContext.xml separately.

Can I just specify datasource.hibernate.cfg.xml as configLocation inside <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"> and get rid of both mappingResources and hibernateProperties. Right now my application context looks like this:

<property name="mappingResources"/>

<list>

<value>../../src/editsolutions.hibernate.cfg.xml</value>

</list>

<property name="hibernateProperties">

<props>

<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>

<prop key="hibernate.connection.isolation">3</prop>

<prop key="hibernate.current_session_context_class">jta</prop>

<prop key="hibernate.transaction.factory_class">

org.hibernate.transaction.JTATransactionFactory

</prop>

<prop key="hibernate.transaction.manager_lookup_class">

com.atomikos.icatch.jta.hibernate.TransactionManagerLookup

</prop>

</props>

</property>

Note: I don't use annotations for entity classes. It's a legacy project and everything is defined via hbm.xml.

网友答案:

You can set 'configLocation' property and get rid of other properties. See

分享给朋友:
您可能感兴趣的文章:
随机阅读: