File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes Spring declaretively transaction not getting rollbacked Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Application Frameworks » Other Application Frameworks
Reply Bookmark "Spring declaretively transaction not getting rollbacked" Watch "Spring declaretively transaction not getting rollbacked" New topic
Author

Spring declaretively transaction not getting rollbacked

Kunaal A Trehan
Ranch Hand

Joined: Feb 04, 2004
Posts: 63
Hi All

I am using spring's declartive transaction mechanism
I am trying to insert 2 rows .One row is fine
But other row has null field in not null column

When I am trying to insert it ,first row gets inserted
But other row does not because of bad data
However whole trnsaction shd be rollback

Here is the code snippet
==========================================
public class TradeDAOImpl extends HibernateDaoSupport
{
public void saveTrade(IProduct iProduct) {

Session session = null;

IProduct temp=new Swap();
temp.setIsSwapswire(new Boolean(false));
temp.setManualTicketYN(new Boolean(false));
temp.setProductId(null);
temp.setTradeFeedTypeId(iProduct.getTradeFeedTypeI d());
temp.setTradeId(iProduct.getTradeId());
temp.setTraderGroupId(iProduct.getTraderGroupId()) ;


session=getSession();

try{
session.save(iProduct);//THIS DATA IS FINE
session.save(temp);//WRONG DATA
}catch(HibernateException ex)
{
ex.printStackTrace();
throw convertHibernateAccessException(ex);
}
finally{
session.close();
}
}
========

Here is my config file details
<bean id="myTxManager" class="org.springframework.transaction.jta.WebLogi cJtaTransactionManager"/>

<bean id="myTransactionFactory" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
<property name="transactionManager" ref="myTxManager"/>
<property name="target" ref="hibernate.tradeDAO"/>
<property name="transactionAttributes">
<props>
<prop key="saveTrade*">PROPAGATION_REQUIRED,-HibernateException</prop>
<prop key="update*">PROPAGATION_REQUIRED,-HibernateException</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly,-HibernateException</prop>
</props>
</property>
</bean>

<bean id="myDataSource" class="org.springframework.jndi.JndiObjectFactoryB ean">
<property name="jndiName" value="EblotterDS"/>
</bean>



Plz help me as I am stuck in this
Thnx
Kunal
Paul Lester
Ranch Hand

Joined: Dec 27, 2002
Posts: 40
I'm not quite sure, but my guess is that your wild card,



key="*" is getting evaluated before the specifics (saveTrade, update*), giving you no rollback, since you've declared it as read only. As an experiment, try removing the wildcard entry and see if it works.

Paul


Where Photography meets vision.<br /><a href="http://www.photogravision.com" target="_blank" rel="nofollow">http://www.photogravision.com</a><br />Please stop by!<br /> <br />SCJP,SCWCD,SCJD,SCEA
 
 
subject: Spring declaretively transaction not getting rollbacked
 
Threads others viewed
unsatisfied Dependancy exception
JDBCContext returning TransactionManager as null
Hiberante transaction in Spring
Questions about tx in Spring
Spring Framework and Hibernate
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com