您的位置:程序门 -> java -> 框架、开源



spring 2.5 +hibernate 3.2 事务管理


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


spring 2.5 +hibernate 3.2 事务管理
发表于:2008-01-18 19:52:41 楼主
小弟刚刚开始接触,看过一些资料,实际操作中可以实现利用org.springframework.transaction.interceptor.transactionproxyfactorybean实现spring事务,但是了解到那种实现是1.0的时候配置方法,现在想实现spring2.0推举的配置方法,以下是配置文件:
<?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="proxooldatasource"   class="org.logicalcobwebs.proxool.proxooldatasource">
<property   name="driver"   value="com.mysql.jdbc.driver"/>
                <property   name="driverurl"   value="jdbc:mysql://localhost:3306/demo?user=dbroot&amp;password=111111&amp;useunicode=true&amp;characterencoding=utf8"/>
                <property   name="user"   value="dbroot"/>
                <property   name="password"   value="111111"/>
<property   name="housekeepingsleeptime"   value="90000"/>
                <property   name="prototypecount"   value="5"/>
                <property   name="maximumconnectioncount"   value="20"/>
                <property   name="minimumconnectioncount"   value="3"/>
                <property   name="trace"   value="true"/>
                <property   name="verbose"   value="true"/>
</bean>

<bean   id="hibernatesessionfactory"     class="org.springframework.orm.hibernate3.localsessionfactorybean">
<property   name="datasource"> <ref   local="proxooldatasource"/> </property>
<property   name="hibernateproperties">
<props>
<!--   数据库方言   -->
<prop   key="hibernate.dialect"> org.hibernate.dialect.mysqldialect </prop>
<prop   key="hibernate.connection.provider_class"> org.hibernate.connection.proxoolconnectionprovider </prop>
<prop   key="hibernate.show_sql"> true </prop>
<prop   key="hibernate.bytecode.use_reflection_optimizer"> true </prop>
<prop   key="hibernate.proxool.existing_pool"> true </prop>
</props>
</property>
<property   name="mappingresources">
<list>
<value> hellovisitor.hbm.xml </value>
</list>
</property>
</bean>

<bean   id="hibernatetransactionmanager"   class="org.springframework.orm.hibernate3.hibernatetransactionmanager">
<property   name="sessionfactory">
<ref   local="hibernatesessionfactory"/>
</property>
</bean>

<tx:advice   id="boadvice"   transaction-manager="hibernatetransactionmanager"   >
<tx:attributes>
<!--   hibernate   transaction   for   read   and   wirte   -->
<tx:method   name="do*"   propagation="required"   isolation="default"   timeout="-1"   read-only="false"   rollback-for="java.lang.exception"/>
<!--   hibernate   transaction   for   read   only   -->
<tx:method   name="get*"   propagation="required"   isolation="default"   timeout="-1"   read-only="true"/>
</tx:attributes>
</tx:advice>

<aop:config   proxy-target-class="true">
<aop:advisor   advice-ref="boadvice"   pointcut="EXECution(*   *.bo.*.*(..))"   />
</aop:config>

<bean   id="helledao"   class="sdu.sc.yxy.wwshdemo.hello.dao.hellodao">
<property   name="sessionfactory">
<ref   bean="hibernatesessionfactory"/>
</property>
</bean>
<bean   id="hellobo"     class="sdu.sc.yxy.wwshdemo.hello.bo.hellobo">
<property   name="hellodao">
<ref   local="helledao"/>
</property>
</bean>

</beans>

可是实际情况是这种配置没有任何效果,即使抛出异常也不行,即事务也不回滚,请那位高手指点一下,不胜感谢!
发表于:2008-01-18 20:54:241楼 得分:0
帮帮忙吧!!!
发表于:2008-01-18 22:34:202楼 得分:0
还是自己解决吧,问了问spring   官方论坛,人家2min就回了。回答在这里


快速检索

最新资讯
热门点击