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: Bug in MultipleHiLoPerTableGenerator class
PostPosted: Mon Jun 16, 2008 12:02 pm 
Newbie

Joined: Mon Jun 16, 2008 11:31 am
Posts: 2
Hibernate version: 3.2.6

Hi guys! I want to ask is it a feature :) of hibernate or it is a bug. And if it is a bug is it already fixed in new version or not.

Class MultipleHiLoPerTableGenerator.
Method: generate

Here we have next code:

Code:
if (lo>maxLo) {
    int hival = ( (Integer) doWorkInNewTransaction(session) ).intValue();
    lo = (hival == 0) ? 1 : 0;
    hi = hival * (maxLo+1);
    log.debug("new hi value: " + hival);
}


maxLo is a private variable of type int. hival variable is also a variable of int type.

hival * (maxLo+1) - the result of this multiplication will also have an int type.
And in case of big values of one of the variables (hival or maxLo) we will have overflow and get a negative value.

example:
hival = 63496364
maxLo = 49;
hival * (maxLo+1) = -1120149096


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 16, 2008 1:13 pm 
Newbie

Joined: Mon Jun 16, 2008 11:31 am
Posts: 2
Found. This is a bug:

http://opensource.atlassian.com/project ... e/HHH-1869

Wish it will be fixed in next version.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 17, 2008 4:11 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Nice digging! I was wondering about this myself.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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.