2009-12-27 81 views
3

我知道我的配置是直接在applicationContext.xml上完成的,我沒有persistence.xml。默認情況下這是resource_loca或jta?如果我想使用jta,是否需要添加額外的參數?春季休眠配置默認使用resource_local或jta?

<bean id="dataSource" 
     class="org.springframework.jdbc.datasource.DriverManagerDataSource"> 
     <property name="driverClassName"> 
      <value>oracle.jdbc.driver.OracleDriver</value> 
     </property> 
      <!-- xdb is defined by running the hsqldb as xdb (see above) --> 
     <property name="url"> 
      <value>jdbc:oracle:thin:@theserver:1521:appsdb</value> 
     </property> 
     <property name="username"> 
      <value>test</value> 
     </property> 
     <property name="password"> 
      <value>test</value> 
     </property> 
    </bean> 




<bean id="annotatedsessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> 


    <property name="packagesToScan" value="com.company.x.model" > 
    </property> 


    <property name="hibernateProperties"> 
     <props> 

      <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop> 
      <prop key="hibernate.show_sql">true</prop> 
      <prop key="hibernate.format_sql">true</prop> 
      <prop key="hibernate.use_sql_comments">true</prop> 
      <prop key="hibernate.cglib.use_reflection_optimizer">true</prop> 
      <prop key="hibernate.hbm2ddl.auto">update</prop> 
      <prop key="hibernate.c3p0.min_size">5</prop> 
      <prop key="hibernate.c3p0.max_size">20</prop> 
      <prop key="hibernate.c3p0.timeout">1800</prop> 
      <prop key="hibernate.c3p0.max_statements">50</prop> 
      <prop key="hibernate.cache.provider_class"> 
        com.company.x.services.ExternalEhCacheProvider 
      </prop> 
      <prop key="hibernate.cache.use_second_level_cache">true</prop> 
      <prop key="hibernate.cache.use_query_cache">true</prop> 



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

</bean> 

回答

4

RESOURCE_LOCAL僅適用於JPA EntityManager,而不是一個Hibernate SessionFactory。 Hibernate的Spring集成比JPA更平滑,因此決定事務行爲的唯一因素是您使用哪個事務管理器(HibernateTransactionManagerJtaTransactionManager)。它可以與任何一個協同工作,而無需明確配置SessionFactory