-->
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.  [ 1 post ] 
Author Message
 Post subject: Howto force a version update
PostPosted: Wed Sep 12, 2007 5:00 pm 
Newbie

Joined: Wed Sep 12, 2007 3:44 pm
Posts: 1
Hibernate version: 3.2

Name and version of the database you are using: MySQL 5


Hi,

I'd like to force an update on the version of an entity, even if no changes occurred. It seems like the LockMode FORCE does just this, but it also locks the entity pessimisticly, which I really don't want to.

Is there a way to force a version update without a pessimistic lock of the entitiy?

Here is what I need this for (if you are interested):
For performance reasons, I need to store the cardinality of a referenced collection in my entity. For this I update the reference count via a scheduled job (the value does not have to be up-to-date). This job compares the version timestamp of the referenced collection elements and the entity and updates the reference count, if an entry in the collection is newer than the entitiy. However, if the reference count is already correct on my entity, Hibernate recognizes that the entity is not dirty and does not update it, so the version does not change. The result is, that the next job picks up the entity again, and so on (if no collection element is added).

I know this is propably not the intended usage for the version, but it would be the most efficient way I can think of.

Any hints are greatly appreciated!

Kai


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

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.