2009-12-27 4 views
3

puis-je savoir que ma configuration est faite directement sur applicationContext.xml, je n'ai pas persistence.xml. par défaut c'est resource_loca ou jta? Ai-je besoin d'ajouter un paramètre supplémentaire si je veux utiliser jta?configuration hibernate de printemps en utilisant resource_local ou jta par défaut?

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

Répondre

4

RESOURCE_LOCAL applique uniquement aux JPA EntityManager, pas à une mise en veille prolongée SessionFactory. L'intégration Spring d'Hibernate est plutôt plus fluide qu'avec JPA, et donc la seule chose qui détermine le comportement transactionnel est le gestionnaire de transactions que vous utilisez avec (HibernateTransactionManager ou JtaTransactionManager). Cela fonctionnera avec l'un ou l'autre sans avoir à configurer explicitement le SessionFactory.