Hi,
I' getting some weird id numbers generated for the following declaration on Postgresql:
Code:
<id name="id" type="long">
<generator class="seqhilo">
<param name="sequence">ProductSeq</param>
<param name="max_lo">100</param>
</generator>
</id>
My assumption was that if next value id equals, say, 100 and max_lo=100 (see above) then HB will use number from 100 to 200 next id numbers (as it would be in the underlying sequence in Postgresql). However, HB uses some strange logic to generate ids that are in the range of 11000+. Why is this necessary? For me it creates a problem since now there's mismatch between sequence values in HB and Postgresql and, as a result, scripts that directly work with Pg sequences (and not through HB) may break.
Any ideas? Thanks
Code:
public synchronized Serializable generate(SessionImplementor session, Object obj) throws SQLException, HibernateException {
if ( lo>maxLo ) {
long hival = ( (Number) super.generate(session, obj) ).longValue();
lo = 1;
hi = hival * ( maxLo+1 );
log.debug("new hi value: " + hival);
}
return IdentifierGeneratorFactory.createNumber( hi + lo++, returnClass );
}