当前位置:首页 > 企业简介 >

使用aop配置事务

编辑:北京飞炫空间展览展示有限公司 时间:2017-09-09 10:21:30阅读次数:2
使用aop配置事务 [html]

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:aop="http://www.springframework.org/schema/aop"

xmlns:tx="http://www.springframework.org/schema/tx"

xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-2.0.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-2.0.xsd

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">

<bean id="phrDS"

class="org.springframework.jdbc.datasource.DriverManagerDataSource">

<property name="driverClassName"

value="org.logicalcobwebs.proxool.ProxoolDriver" />

<property name="url" value="proxool.phrConn" />

</bean>

<bean id="cdaDS"

class="org.springframework.jdbc.datasource.DriverManagerDataSource">

<property name="driverClassName"

value="org.logicalcobwebs.proxool.ProxoolDriver" />

<property name="url" value="proxool.cdaConn" />

</bean>

<!-- CDA

<bean id="cdaDS"

class="org.springframework.jdbc.datasource.DriverManagerDataSource">

<property name="driverClassName">

<value>oracle.jdbc.driver.OracleDriver</value>

</property>

<property name="url">

<value>${dbconn.cda.url}</value>

</property>

<property name="username">

<value>${dbconn.cda.userName}</value>

</property>

<property name="password">

<value>${dbconn.cda.password}</value>

</property>

</bean> -->

<!--文档数据库数据源配置-Oracle数据源配置 -->

<bean id="docstoreDS"

class="org.springframework.jdbc.datasource.DriverManagerDataSource">

<property name="driverClassName">

<value>oracle.jdbc.driver.OracleDriver</value>

</property>

<property name="url">

<value>${dbconn.docstore.url}</value>

</property>

<property name="username">

<value>${dbconn.docstore.userName}</value>

</property>

<property name="password">

<value>${dbconn.docstore.password}</value>

</property>

</bean>

<bean id="phrSessionFactory"

class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

<property name="dataSource" ref="phrDS" />

<property name="mappingDirectoryLocations">

<list>

<value>${dbconn.docstore.mappingDirectory}</value>

</list>

</property>

<property name="hibernateProperties">

<props>

<prop key="hibernate.dialect">

${dbconn.docstore.dialect}

</prop>

<prop key="hibernate.show_sql">

${dbconn.docstore.showsql}

</prop>

<prop key="hibernate.format_sql">true</prop>

<prop key="hibernate.cache.use_second_level_cache">

false

</prop>

<prop key="hibernate.cache.provider_class">

org.hibernate.cache.EhCacheProvider

</prop>

<prop key="hibernate.cache.use_query_cache">false</prop>

<!--<prop key="current_session_context_class">jta</prop>

<prop key="hibernate.transaction.factory_class">

org.hibernate.transaction.JTATransactionFactory

</prop>

for jta compatilibility (jta)

org.hibernate.context.JTASessionContext

-->

<prop key="hibernate.cglib.use_reflection_optimizer">

true

</prop>

</props>

</property>

</bean>

<bean id="cdaSessionFactory"

class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

<property name="dataSource" ref="cdaDS" />

<property name="mappingDirectoryLocations">

<list>

<value>${dbconn.docstore.mappingDirectory}</value>

</list>

</property>

<property name="hibernateProperties">

<props>

<prop key="hibernate.dialect">

${dbconn.docstore.dialect}

</prop>

<prop key="hibernate.show_sql">

${dbconn.docstore.showsql}

</prop>

<prop key="hibernate.format_sql">true</prop>

<prop key="hibernate.cache.use_second_level_cache">

false

</prop>

<prop key="hibernate.cache.provider_class">

org.hibernate.cache.EhCacheProvider

</prop>

<prop key="hibernate.cache.use_query_cache">false</prop>

<!--

for jta compatilibility (jta)

org.hibernate.context.JTASessionContext

<prop key="current_session_context_class">jta</prop>

<prop key="hibernate.transaction.factory_class">

org.hibernate.transaction.JTATransactionFactory

</prop>-->

</props>

</property>

</bean>

<!-- Template配置 -->

<bean id="phrJDBCTemplate"

class="org.springframework.jdbc.core.JdbcTemplate">

<property name="dataSource" ref="phrDS" />

</bean>

<!-- HibernateTemplete 配置 -->

<bean id="phrHibernateTemplete"

class="org.springframework.orm.hibernate3.HibernateTemplate">

<property name="sessionFactory" ref="phrSessionFactory" />

</bean>

<!-- HibernateDAO配置 -->

<bean id="phrHibernateDao"

class="com.xbzc.phr.dao.HibernateSuperDAOImpl">

<property name="sessionFactory" ref="phrSessionFactory" />

</bean>

<!-- HibernateDAO配置-CDA查看使用 -->

<bean id="cdaHibernateDao"

class="com.xbzc.phr.dao.CdaHibernateSuperDAOImpl">

<property name="sessionFactory" ref="cdaSessionFactory" />

</bean>

<span style="color:#ff0000;"> <bean id="springTransactionManager"

class="org.springframework.orm.hibernate3.HibernateTransactionManager">

<property name="sessionFactory" ref="phrSessionFactory" />

</bean>

<!-- 通知配置-->

<tx:advice id="txAdvice"

transaction-manager="springTransactionManager">

<tx:attributes>

<tx:method name="save*" propagation="REQUIRED" rollback-for="DaoException"/>

</tx:attributes>

</tx:advice>

<!-- 事务切面配置 ,配置参与事务的类-->

<aop:config>

<aop:pointcut id="point"

expression=" execution(* com.xbzc.phr.service.um.UserManageSrv.*(..))" />

<!-- 指定使用jta事务的类、方法 -->

<aop:advisor advice-ref="txAdvice" pointcut-ref="point" />

</aop:config>

</span></beans>

企业建站2800元起,携手武汉肥猫科技,做一个有见地的颜值派!更多优惠请戳:武汉网络推广 https://www.feimao666.com

上一篇:浅谈网站logo的几个制作标准 下一篇:最后一页

相关阅读