Hi there,
I am new in Spring and trying to apply aop in my projects...
But my transaction is not rolling back..
To testing inserting 1st table than in second table insert I throwin a RuntimeException, but first table is goting saved..
Here is my spring configuration file..
]Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd "> <bean class="org.springframework.jdbc.datasource.DriverManagerDataSource" id="dataSource"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /> <property name="url" value="jdbc:oracle:thin:@localhost/xe" /> <property name="username" value="test_db" /> <property name="password" value="TEST_DB" /> </bean> <bean class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" id="sessionFactory"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop> <!-- prop key="hibernate.hbm2ddl.auto">update</prop --> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.use_sql_comments">true</prop> <prop key="hibernate.cache.use_second_level_cache">false</prop> </props> </property> <property name="annotatedClasses"> <list> <value>net.opensesam.entity.User</value> <value>net.opensesam.entity.MusterigrubuInfo</value> </list> </property> </bean> <bean class="net.opensesam.bo.UserBoImpl" id="userBoImpl"> <constructor-arg ref="sessionFactory"></constructor-arg> </bean> <bean class="net.opensesam.bo.MusteriGrubuBoImpl" id="musteriGrubuBoImpl"> <constructor-arg ref="sessionFactory"></constructor-arg> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="*" /> </tx:attributes> </tx:advice> <aop:config> <aop:advisor advice-ref="txAdvice" pointcut="execution(* net.opensesam.bo.*.*(..))" /> </aop:config> </beans>
And this is my first BusinesObject implementation
Code:package net.opensesam.bo; import net.opensesam.dao.AbstractDao; import net.opensesam.entity.User; import org.hibernate.SessionFactory; public class UserBoImpl extends AbstractDao<User> implements CommonBo { public UserBoImpl(SessionFactory sessionFactory) { super(User.class, sessionFactory); } @Override public Object findById(int id) { return get(id); } @Override public void insert(Object user) { save((User) user); } }
And the second BusinessObject implementation..
Code:package net.opensesam.bo; import net.opensesam.dao.AbstractDao; import net.opensesam.entity.MusterigrubuInfo; import org.hibernate.SessionFactory; public class MusteriGrubuBoImpl extends AbstractDao<MusterigrubuInfo> implements CommonBo { public MusteriGrubuBoImpl(SessionFactory sessionFactory) { super(MusterigrubuInfo.class, sessionFactory); } @Override public Object findById(int id) { return get(id); } @Override public void insert(Object user) { if (true) throw new RuntimeException(); save((MusterigrubuInfo) user); } }
And full code is attached..
I think I am ignoring sometihng but what..
Thanks for help by now..


Reply With Quote
