JDO Exception in google app engine transaction

Posted by Mariselvam on Stack Overflow See other posts from Stack Overflow or by Mariselvam
Published on 2010-12-11T18:44:09Z Indexed on 2010/12/31 23:54 UTC
Read the original article Hit count: 218

Filed under:
|
|

I am getting the following exception while trying to use transation in app engine datastore.

javax.jdo.JDOUserException: Transaction is still active. You should always close your transactions correctly using commit() or rollback(). FailedObject:org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManager@12bbe6b at org.datanucleus.jdo.JDOPersistenceManager.close(JDOPersistenceManager.java:277)

The following is the code snippet I used :

List<String> friendIds = getFriends(userId);
Date currentDate = new Date();
PersistenceManager manager = pmfInstance.getPersistenceManager();
try {
Transaction trans = manager.currentTransaction();
trans.begin();
for(String friendId : friendIds) {
User user = manager.getObjectById(User.class, friendId);
if(user != null) {
user.setRecoCount(user.getRecoCount() + 1);
user.setUpdatedDate(currentDate);
manager.makePersistent(user);
}
}
trans.commit();
} finally {
manager.close();
}

© Stack Overflow or respective owner

Related posts about google-app-engine

Related posts about app