-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Spring managed transaction issue with Teradata
PostPosted: Wed Apr 13, 2011 2:00 pm 
Newbie

Joined: Wed Apr 13, 2011 9:31 am
Posts: 1
In my application, hibernate transactions are managed by spring aop and uses Terdata as database.

THIS ISSUES IS SPECIFIC TO TERADATA AND THE SAME CODES WORKS FINE IN MYSQL.

There is one service class i.e. ServiceClass.

It has method called save which takes list of objects as parameters and checks whether it is modified or not by checking it with data from database.

After that it calls the DAO class which persist the data in database.

ServiceClass method's aop:

<tx:advice id="txAdviceForService"
transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save" isolation="READ_COMMITTED"/>
</tx:attributes>
</tx:advice>

ServiceClass:

public void save(List<Test> testList) {
DAOClass daoClass;

boolean isUpdated = false ;
for (Test test : testList) {
Test testInDB = this.sessionFactory.getCurrentSession().get(
Test.class, test.getId());
if(! test.getName().equals(testIndDB)) {
isUpdated = true ;
break;
}

}

daoClass.save(testList);

if(isUpdated) {
// do some processing
}
}



DAOClass:


public void save(List<Test> testList) {

for (Test test : testList) {
try {
this.sessionFactory.getCurrentSession().saveOrUpdate(test);
session.flush();

} catch (HibernateException e) {
///
}

}

}

DAOClass method's aop:
<tx:advice id="txAdviceForDAO"
transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save" propagation="REQUIRES_NEW" />
</tx:attributes>
</tx:advice>


Transaction management code:
<aop:config>
<aop:advisor advice-ref="txAdviceForService"
pointcut="execution(* ServiceClass.*(..))" />
<aop:advisor advice-ref="txAdviceForDAO"
pointcut="execution(* DAOClass.*(..))" />
</aop:config>

Here, when service class calls save method of DAO class, it starts in new transaction as mentioned above in AOP code..

The issue is service class reads object from database in one transaction and then it calls method which starts a new transaction to save data.
When it calls session.flush, the table gets locked and can't get accessed even from outside application and the application gets hanged.


If i put the code of saving data from DAO to service class then it works fine as because it is under same transaction.

Has any body face similar issue while using Hibernate with Teradata (with spring managed transaction) ?

Regards,

Chirag


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.