Spring2.5 Hibernate Transaction Q(Changes New)
Today ,i hava just got the newest spring 2.5 and then i want to test its new transaction declare. I use the spring 1 style to handle the hibernate transaction. Then i got the right answer(it rolls back. i works);
but when i use tx:advice then i does not work. i do not know why
here is my applicationContext, and i use the webApplicationContextListen to load it.
PHP Code:
<?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&password=111111&useUnicode=true&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>
<aop:config proxy-target-class="true">
<aop:advisor advice-ref="boAdvice" pointcut="execution(* *.bo.*.*(..))" />
</aop:config>
<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>
<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>
Then ,i want to webAction to use the helloBo ,because of checking exception in webAction , so i want to handle the exception in bo,like
PHP Code:
interface IA{
String b();
}
class A implement IA{
String b(){
try{
doB();
}catch(Exception e){
return e.getMessage();
}
return null;
}
void doB() throws Exception{
...........
}
}
but in fact ,that does not works . if i just handle the doB() in webAction ,i works .i want to know why?