Spring和Hibernate:将cfg.xml加载到应用程序上下文中
Spring和Hibernate:将cfg.xml加载到应用程序上下文中,spring,hibernate,Spring,Hibernate,datasource.hibernate.cfg.xml具有HibernateProperty和所有映射资源 但是现在我必须在applicationContext.xml中分别定义映射资源和属性。 我是否可以在内部将datasource.hibernate.cfg.xml指定为configLocation,并去掉映射资源和hibernateProperties。现在,我的应用程序上下文如下所示: <property name="mappingResources"/>
datasource.hibernate.cfg.xml
具有HibernateProperty和所有映射资源但是现在我必须在
applicationContext.xml
中分别定义映射资源和属性。我是否可以在
内部将datasource.hibernate.cfg.xml指定为configLocation
,并去掉映射资源和hibernateProperties
。现在,我的应用程序上下文如下所示:
<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>
../../src/editsolutions.hibernate.cfg.xml
org.hibernate.dialogue.sqlserverdialogue
3.
jta
org.hibernate.transaction.JTATransactionFactory
com.atomikos.icatch.jta.hibernate.TransactionManagerLookup
注意:我不对实体类使用注释。这是一个遗留项目,所有内容都是通过
hbm.xml
定义的。您可以设置“configLocation”属性并删除其他属性