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;
}