-->
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: Adding version to an existing object
PostPosted: Thu Oct 15, 2009 9:39 pm 
Newbie

Joined: Thu Oct 15, 2009 9:30 pm
Posts: 4
We're adding versioning to several of our objects so that we can do optimistic-locking on our writes. Granted, we should have done this from the start. But... since it would be really expensive in our production databases to set version = 0 for all of the rows, I'm wondering if there is a nice way to handle the fact that at first all of the versions will be NULL.

I've considered triggers in the database, etc but none of that will help because the update statement will be expecting the version to be something other than NULL I believe.

Regards,

Pete


Top
 Profile  
 
 Post subject: Re: Adding version to an existing object
PostPosted: Sat Dec 12, 2009 3:02 am 
Newbie

Joined: Sat Dec 12, 2009 2:59 am
Posts: 2
I am running into a similar issue that i cannot update all existing records to have a value for the version column. This is problematic because hibernate seems to fail when it tries to update such records. I believe the update query fails because of the null. Has anyone figured out a way around this? The only way i could think of was to write a named query and use executeUpdate() but in the query do something like this:

UPDATE
...
..
where id = ? and version IS NULL /* as opposed to "version = ?" which does not seem to work */


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.