-->
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.  [ 6 posts ] 
Author Message
 Post subject: Possible reasons/scenarios for a StaleObjectException?
PostPosted: Fri Apr 07, 2006 12:31 pm 
Newbie

Joined: Sat May 21, 2005 10:16 pm
Posts: 15
Greetings,

I am getting random StaleObjectExcpetions on save/updates and I am not sure why (not sure as in I do not think the object is actually stale).

Besides the actual object data changing since the last load/refresh of the object – what else could cause this?

I am using .NET Remoting, using the session.SaveOrUpdateCopy for all instances where I need to save/update an object – is this appropriate?

Many times it will error out with the StaleObjectException, but on the next go around it will save just fine… ?

I use the <Timestamp> versioning, and in my database the column type is DateTime, and it is set to not-null. When a new object is created I set the edit timestamp to the current date time via DateTime.Now

Any insight would be appreciated!

Thanks...


Hibernate version: v1.0.2

Code between sessionFactory.openSession() and session.close():
using (ISession session = mySessFactory.OpenSession())
{
using (ITransaction tx = session.BeginTransaction())
{
try
{
session.SaveOrUpdateCopy(obj);
tx.Commit();
}
catch (Exception ex)
{
tx.Rollback();
}
finally
{
session.Flush();
}
}
}

Name and version of the database you are using:
MySql 5.0


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 07, 2006 1:06 pm 
Senior
Senior

Joined: Sat May 14, 2005 8:40 am
Posts: 130
Are you running on Mono by any change? I have encountered the same issue on Mono with PostgreSQL. It seems to be some datetime rounding problem (hence the random failure). However, I still haven't found how to fix it.

_________________
Cuyahoga


Top
 Profile  
 
 Post subject: No Mono
PostPosted: Fri Apr 07, 2006 4:12 pm 
Newbie

Joined: Sat May 21, 2005 10:16 pm
Posts: 15
Greetings,

No Mono - have .NET v1.1 as well as .NET v2.0 installed on this machine....


Top
 Profile  
 
 Post subject: Any ideas?
PostPosted: Mon Apr 10, 2006 7:35 am 
Newbie

Joined: Sat May 21, 2005 10:16 pm
Posts: 15
Any ideas?


Top
 Profile  
 
 Post subject: No?
PostPosted: Tue Apr 11, 2006 8:26 pm 
Newbie

Joined: Sat May 21, 2005 10:16 pm
Posts: 15
No?


Top
 Profile  
 
 Post subject: Re: Possible reasons/scenarios for a StaleObjectException?
PostPosted: Wed Apr 12, 2006 4:43 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
Cable wrote:
Greetings,
Code between sessionFactory.openSession() and session.close():
using (ISession session = mySessFactory.OpenSession())
{
using (ITransaction tx = session.BeginTransaction())
{
try
{
session.SaveOrUpdateCopy(obj);
tx.Commit();
}
catch (Exception ex)
{
tx.Rollback();
}
finally
{
session.Flush();
}
}
}

Name and version of the database you are using:
MySql 5.0


Not sure if this is case, but: You are flushing the session AFTER the tarnsaction is committed or rolled back. Maybe You should get rid of Session.Flush all together as transaction.Commit has already executed it....

Gert


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.