views:

283

answers:

1

may i know as my configuration is done directly on applicationContext.xml, i do not have persistence.xml . by default this is resource_loca or jta? do i need to add extra parameter if i want to use 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>
+2  A: 

RESOURCE_LOCAL only applies to JPA EntityManager, not to a Hibernate SessionFactory. Hibernate's Spring integration is rather smoother than it is with JPA, and so the only thing that determines the transactional behaviour is which transaction manager you use with it (either HibernateTransactionManager or JtaTransactionManager). It'll work with either one without you having to explicitly configure the SessionFactory.

skaffman