-
Jan 18th, 2008, 03:12 AM
#1
Problem with declarative transaction management
I am facing some problem with TransactionProxyFactoryBean.When i am doing the transaction rollback also it is saving......
My code is:
applicationContext.xml
<bean id="userdao" class="com.impl.UserDAOImpl">
<property name="sessionFactory">
<ref local="sesfactory1" />
</property>
</bean>
<bean id="userManagerTarget" class="com.impl.UserManagerImpl">
<property name="userDAO">
<ref local="userdao" />
</property>
</bean>
<bean id="transactionManager1"
class="org.springframework.orm.hibernate3.Hibernat eTransactionManager">
<property name="sessionFactory">
<ref local="sesfactory1" />
</property>
</bean>
<bean id="userManager"
class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
<property name="transactionManager">
<ref local="transactionManager1" />
</property>
<property name="target">
<ref local="userManagerTarget" />
</property>
<property name="transactionAttributes">
<props>
<prop key="getUserList">
PROPAGATION_REQUIRES_NEW,-com.Testexception
</prop>
<prop key="insert*">
PROPAGATION_REQUIRED,-com.Testexception
</prop>
</props>
</property>
</bean>
UserDAOImpl.java
public List getList()
{
AgUser aguser=new AgUser();
aguser.setCity("rvp");
aguser.setName("Naren");
aguser.setDob(new java.util.Date());
aguser.setZipcode(new Long(234));
//System.out.println(getHibernateTemplate());
getHibernateTemplate().save(aguser);
System.out.println("After saving...");
Session ses=getSession();
l1=ses.createCriteria(AgUser.class).list();
System.out.println(l1.size());
return null;
}
UserManagerImpl.java
public List getUserList() throws com.Testexception
{
List l1=null;
try
{
l1=userdao.getList();
System.out.println("size in UsermanagerImpl---"+l1.size());
}
catch(Exception e)
{
System.out.println("----->"+e.getMessage());
//e.printStackTrace();
throw new com.Testexception();
}
Client Program
ApplicationContext ctx =
new ClassPathXmlApplicationContext(new String []{"applicationContext.xml"});
UserManagerImpl um=(UserManagerImpl)ctx.getBean("userManagerTarget ");
List l2=null;
try
{
l2=um.getUserList();
}
catch(Exception e)
{
System.out.println("No Error");
}
even though i am raising Testexception explicitly the recording is saving successfully..... what is wrong in my code
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules