2013-03-26 80 views
0

datasource.hibernate.cfg.xml具有hiberanteProperties和所有映射资源。
但是现在我必须分别在applicationContext.xml中定义映射资源和属性。
我可以在<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">内指定datasource.hibernate.cfg.xml作为configLocation,并且同时删除mappingResources and hibernateProperties。现在我的应用程序上下文看起来像这样:Spring和Hibernate:将cfg.xml加载到应用程序上下文中

<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> 

注意:我不使用实体类的注释。这是一个遗留项目,所有内容都通过hbm.xml定义。

回答

1

您可以设置'configLocation'属性并摆脱其他属性。 See

相关问题