-->
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.  [ 3 posts ] 
Author Message
 Post subject: Version property
PostPosted: Tue Oct 12, 2004 4:00 pm 
Beginner
Beginner

Joined: Mon Feb 23, 2004 5:11 pm
Posts: 39
Hibernate version:
Hibernate 2.1

Code between sessionFactory.openSession() and session.close():Session session = HibernateAbstractSessionUtil.getCurrentSession();
Transaction tx = session.beginTransaction();
CompanyOpsArea coa = (CompanyOpsArea) session.load(CompanyOpsArea.class, new Long(1));
tx.commit();
session.close();

Name and version of the database you are using:
Oracle 9

All data is versioned. After the commit is done, I noticed the version column in the database is incremented.
My questions is:

Why is the version property incremented on a simple read?

This is causing a lot of StaleObjectStaleException when the some CompanyOpsArea is read by multiple concurrent transactions.

Shouldn't the version property really change only when actual data changes?

What are my options here (other than evicting the object before I commit)?

What kind of impact would second-level (fully-transactional JBOSS)caching on this?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 12, 2004 7:15 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Quote:
Why is the version property incremented on a simple read?

Its not.

For whatever reason Hibernate thinks your objects *are* dirty; thats the only time that the version propertied are incremented. So you are doing something in your code to make Hibernate think that. Probably something like using an Interceptor incorrectly, or modifying values in getters/setters, etc.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 13, 2004 9:37 am 
Beginner
Beginner

Joined: Mon Feb 23, 2004 5:11 pm
Posts: 39
God bless you.

We had a property for ChangeDateTime that was always set to new GregorianCalendar().So the object was always dirty.


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