-->
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: TransactionException: Could not register synchronization
PostPosted: Thu Aug 03, 2006 1:42 pm 
Newbie

Joined: Thu Aug 03, 2006 1:13 pm
Posts: 1
Hibernate version: Hibernate3

My Requirement:
I need to query a table and look for entries that are greater than 90 days old and delete them.

So, I'm trying to use session.connection() and call an oracle specific sql statement to achieve this. The table has a create_date column which I use to derive the number of days. Now when this logic gets invoked I receive a "TransactionException" stating "Could not register synchronization", please, see entire stack trace below. Any feedback is much appreciated.

Code between sessionFactory.openSession() and session.close():
public void deleteExpiredToken()
{

Session hibernateSession = null;
Transaction tx = null;
Connection connection= null;

try
{

hibernateSession = getSessionFactory().getCurrentSession();
tx = hibernateSession.beginTransaction();
connection = hibernateSession.connection();

tx.begin();
hibernateSession.connection().createStatement().executeUpdate("delete token_table where floor(SYSDATE-creation_date) > 90");
tx.commit();

hibernateSession.flush();
hibernateSession.close();

} catch....


Full stack trace of any exception that occurs:
org.hibernate.TransactionException: Could not register synchronization
at org.hibernate.transaction.CMTTransaction.registerSynchronization(CMTTransaction.java:159)
at org.hibernate.context.ThreadLocalSessionContext.currentSession(ThreadLocalSessionContext.java:78)
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:507)
at com.symantec.portal.am.security.dao.TokenDao.deleteExpiredToken(TokenDao.java:88)
at com.symantec.portal.am.batch.CleanUpExpiredTokenTask.run(CleanUpExpiredTokenTask.java:46)
at java.util.TimerThread.mainLoop(Timer.java:447)
at java.util.TimerThread.run(Timer.java:397)
Caused by: java.lang.NullPointerException
at org.hibernate.transaction.CMTTransaction.registerSynchronization(CMTTransaction.java:156)
... 6 more


Name and version of the database you are using:
Oracle 9i




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.