-->
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.  [ 2 posts ] 
Author Message
 Post subject: getting Row was updated or deleted by another transaction
PostPosted: Tue Sep 27, 2016 5:41 am 
Newbie

Joined: Tue Sep 27, 2016 5:37 am
Posts: 1
Sorry I am asking the common question
I am getting below exception when two web service calls the same method (getUpdateFragment) and each time calls method isUserValid(). User validation return true but still getting the exception. why only at second call it throws exception, I am calling second web service before first get ended.
Is there a way that both ws call execute separately.

org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.dmainc.commons.security.User#4]

problem method-

Code:
public UpdateFileRequest getUpdateFragment(UpdateFilter filter)
      {
      Session session = null;
      Transaction transaction = null;
     
      UpdateFileRequest request = new UpdateFileRequest();
      UpdateFragmentReleaseFilter releaseFilter = null;
     
      try
      {
         session = HibernateUtils.currentSession();
         transaction = session.beginTransaction();
         
         releaseFilter = new UpdateFragmentReleaseFilter(filter);

         // are the user credentials valid
         if(ServiceUtils.isUserValid(releaseFilter))
         {
          //Getting exception at this place while committing the transacation
           HibernateUtils.commit(transaction);
         }


currentSession method

Code:
public static Session currentSession() throws HibernateException {
      Session s = session.get();
      
      if(s != null)
         s = validateSession(s);
      
      // Open a new Session, if this Thread has none yet
      if (s == null) {
         if (log.isDebugEnabled())
            log.debug("Opening new session");
         s = session_factory.openSession();

         session.set(s);
         new_session.set(Boolean.TRUE);
      } else if (!isNewSession()) {
         new_session.set(Boolean.FALSE);
      }

      return s;
   }


Top
 Profile  
 
 Post subject: Re: getting Row was updated or deleted by another transaction
PostPosted: Tue Sep 27, 2016 11:29 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
What does isUserValid() do?Can you show the code for it?


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

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.