Hi I have following code

SessionUtil.startDbSession(sessionObject.getUserSession());
Forum forum = null;
try{
            forum =
PersistanceHelper.getForumCategoryPersistance().getForumCategoryById(sessionObject.getUserSession(),
forumId);
            System.out.println("1Forum Name = "+ forum.getCategoryName());
        }catch(Exception ex)
        {
            ex.printStackTrace();
        }finally{
            SessionUtil.rollbackDbSession(sessionObject.getUserSession());
        }

System.out.println("2Forum Name = "+ forum.getCategoryName());

Its a quite simple code , SessionUtil class start,commit,rollback JDO
transaction session.
And when i run it i get the output as

1Forum Name = Education
2Forum Name = null


Now if i change the finally block to
SessionUtil.commitDbSession(sessionObject.getUserSession());

i get following outout

1Forum Name = Education
2Forum Name = Education

I am not sure why Rollbacking the transaction making the String field as
null, althou Key field is ok in both the cases. Is it suppose to work like
this or its a defect.
And usually when i know that in one transaction i will only read the data,
then i prefer to rollback then commit.


Following are the function of SessionUtil Class. JDOManager class is wrapper
for JDO Persistance Manger and just keeps things in one place.

public static void startDbSession(UserSession userSession)
    {
        PersistenceManager pm = PMF.get().getPersistenceManager();
        JDOManager dbManager = new JDOManager(pm);
        dbManager.startTransaction();
        userSession.setDbManager(dbManager);
    }
    public static void commitDbSession(UserSession userSession)
    {
        userSession.getDbManager().commitTransaction();
    }
    public static void rollbackDbSession(UserSession userSession)
    {
        userSession.getDbManager().rollbackTransaction();
    }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to