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