Hi Friends,
I am Using Spring AOP. But Roll-backing is not properly working. I am getting bean from Application Context not from Bean Factory and the DataBase is Oracle .
Here is the Code
The value will be save to First table. It is not rollbacked.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/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> <bean id="ContactBo" class="com.ct.contacts.bo.impl.ContactsBoImpl"> <property name="contactsDao" ref="contactsDao" /> <property name="securityDao" ref="TestDao" /> </bean> <bean id="contactsDao" class="com.ct.contacts.dao.impl.ContactsDaoImpl"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <!-- the transactional semantics... --> <tx:attributes> <tx:method name="insert*" propagation="REQUIRED"/> <!-- other methods use the default transaction settings (see below) --> <tx:method name="*"/> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="TestTransactionMethods" expression="execution(* com.ct.contacts.bo.impl.ContactsBoImpl.insert(..))"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="TestTransactionMethods"/> </aop:config> </beans> ------------- Business Class---------------------- package com.ct.contacts.bo.impl; import org.springframework.orm.hibernate3.HibernateTransactionManager; import com.ct.common.MainDto; import com.ct.contacts.dao.ContactsDaoIntf; import com.ct.security.dao.TestDaoIntf; public class ContactsBoImpl implements ContactsBoIntf{ ContactsDaoIntf contactsDao; TestDaoIntf securityDao; public void setSecurityDao(TestDaoIntf securityDao) { System.out.println("in securityyyy"); this.securityDao = securityDao; } public void setContactsDao(ContactsDaoIntf contactsDao) { System.out.println("in setterrrrrrrrrrrrrr"); this.contactsDao = contactsDao; } public void insert(MainDto objMainDto){ try{ System.out.println("in ContactsBoImpl"); contactsDao.insert(objMainDto.getObjContactsDto()); objMainDto.getObjSecurityDto()=null; securityDao.insert(objMainDto.getObjSecurityDto());---------------Creating Null value }catch (Exception ex){ System.out.println("EXCEPTION FOUND --------------------"); ex.printStackTrace(); } } }
Kindly give me a solution,
Aby


Reply With Quote