-->
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 field
PostPosted: Fri Aug 17, 2007 2:19 pm 
Newbie

Joined: Fri Aug 17, 2007 2:11 pm
Posts: 19
Hi

I'm new to Hibernate.

I have created an entity and annotated it with a version field on my table.
Code:
    @Version
    @Column(name = "OBJ_VERSION")
    private int version = 0;


Everything works fine as expected if user B overwrites data already modified by user A - however not able to capture org.hibernate.StaleObjectStateException gracefully in my Seam application (will look into that later)

my question really is what happens when the obj_version field on my table reaches it's maximum value?, how will hibernate do a version check then? - do i need to manually reset this when I realize this or will hibernate recycle and set the version number to 1 and start again.

Thanks
Franco


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 17, 2007 3:26 pm 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
org.hibernate.type.IntegerType:
Code:
public Object next(Object current, SessionImplementor session) {
   return new Integer( ( (Integer) current ).intValue() + 1 );
}


In short, no it doesn't roll over like your odometer. You are aware of Integer.MAX_VALUE and what that implies right?

http://java.sun.com/j2se/1.4.2/docs/api ... .MAX_VALUE

That's a LOT of versions. 2,147,483,647 Not enough? Use long instead. That'll get you all the way up to 9,223,372,036,854,775,807 at which time you are welcome to reply to this thread and I'll provide you with a workaround :)

-Chris

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


Top
 Profile  
 
 Post subject: Version field
PostPosted: Fri Aug 17, 2007 4:15 pm 
Newbie

Joined: Fri Aug 17, 2007 2:11 pm
Posts: 19
And I was sweating for no reason!

Thank you.


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.