Advertisement
Javi

Spring Tx Configuration

Feb 20th, 2012
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 3.75 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2.  
  3. <beans xmlns="http://www.springframework.org/schema/beans"
  4.       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5.       xmlns:p="http://www.springframework.org/schema/p"
  6.       xmlns:context="http://www.springframework.org/schema/context"
  7.       xmlns:tx="http://www.springframework.org/schema/tx"
  8.       xmlns:aop="http://www.springframework.org/schema/aop"
  9.       xsi:schemaLocation="http://www.springframework.org/schema/beans
  10.                           http://www.springframework.org/schema/beans/spring-beans.xsd
  11.                           http://www.springframework.org/schema/context
  12.                           http://www.springframework.org/schema/context/spring-context.xsd
  13.                           http://www.springframework.org/schema/tx
  14.                           http://www.springframework.org/schema/tx/spring-tx.xsd
  15.                           http://www.springframework.org/schema/aop
  16.                           http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
  17.                           http://www.springframework.org/schema/aop
  18.                           http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
  19.  
  20.     <!-- COMMON ************************************************************************** -->
  21.  
  22.     <bean id="log4jInitialization"
  23.          class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"
  24.          lazy-init="false">
  25.         <property name="targetClass"
  26.                  value="org.springframework.util.Log4jConfigurer" />
  27.         <property name="targetMethod" value="initLogging" />
  28.         <property name="arguments">
  29.             <list>
  30.                 <value>classpath:log4j.properties</value>
  31.             </list>
  32.         </property>
  33.     </bean>
  34.    
  35.     <context:spring-configured />
  36.     <context:annotation-config />
  37.     <aop:aspectj-autoproxy />
  38.    
  39.    
  40.  
  41.     <tx:annotation-driven
  42.        transaction-manager="transactionManager"/>
  43.  
  44.     <context:property-placeholder
  45.            location="classpath:database.properties"/>
  46.  
  47.  
  48.     <bean id="dataSource"
  49.          class="org.springframework.jdbc.datasource.DriverManagerDataSource"
  50.          p:driverClassName="${dataSource.driverClassName}"
  51.          p:url="${dataSource.url}"
  52.          p:username="${dataSource.username}"
  53.          p:password="${dataSource.password}"
  54.     />
  55.  
  56.  
  57.     <bean id="entityManagerFactory"
  58.          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
  59.          p:dataSource-ref="dataSource"
  60.          p:persistenceUnitName="data">
  61.         <property name="jpaVendorAdapter">
  62.             <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />            
  63.            
  64.         </property>
  65.         <property name="jpaProperties">
  66.             <props>
  67.                 <prop key="hibernate.hbm2ddl.auto">create</prop>
  68.                 <prop key="hibernate.archive.autodetection">class</prop>
  69.                 <prop key="hibernate.connection.pool_size">1</prop>
  70.                 <prop key="hibernate.dialect">org.hibernate.dialect.DerbyDialect</prop>
  71.                 <prop key="hibernate.current_session_context_class">thread</prop>
  72.                 <prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
  73.                 <prop key="hibernate.show_sql">true</prop>
  74.                 <prop key="hibernate.format_sql">true</prop>
  75.                 <prop key="hibernate.use_sql_comments">true</prop>
  76.             </props>
  77.         </property>
  78.     </bean>
  79.  
  80.     <bean id="transactionManager"
  81.          class="org.springframework.orm.jpa.JpaTransactionManager"
  82.          p:entityManagerFactory-ref="entityManagerFactory"
  83.     />
  84.  
  85.  
  86.                                
  87.                    
  88. </beans>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement