@Test public void testHiLoAlgorithm() { SessionImpl session = (SessionImpl) sessionFactory.openSession(); session.beginTransaction(); assertEquals( 0L, extractSequenceValue( session ) ); Long generatedValue = (Long) generator.generate( session, null ); assertEquals( 4L, generatedValue.longValue() ); assertEquals( 1L, extractSequenceValue( session ) ); generatedValue = (Long) generator.generate( session, null ); assertEquals( 5L, generatedValue.longValue() ); assertEquals( 1L, extractSequenceValue( session ) ); generatedValue = (Long) generator.generate( session, null ); assertEquals( 6L, generatedValue.longValue() ); assertEquals( 1L, extractSequenceValue( session ) ); generatedValue = (Long) generator.generate( session, null ); assertEquals( 7L, generatedValue.longValue() ); assertEquals( 1L, extractSequenceValue( session ) ); generatedValue = (Long) generator.generate( session, null ); assertEquals( 8L, generatedValue.longValue() ); assertEquals( 2L, extractSequenceValue( session ) ); session.getTransaction().commit(); session.close(); }
public synchronized Serializable generate(final SessionImplementor session, Object obj) { if ( maxLo < 1 ) { IntegralDataTypeHolder value = null; while ( value == null || value.lt( 0 ) ) { value = super.generateHolder( session ); } return value.makeValue(); } return hiloOptimizer.generate( new AccessCallback() { public IntegralDataTypeHolder getNextValue() { return generateHolder( session ); } } ); }
SequenceHiLoGenerator extends SequenceGenerator { public synchronized Serializable generate(final SessionImplementor session, Object obj) { if ( maxLo < 1 ) { IntegralDataTypeHolder value = null; while ( value == null || value.lt( 0 ) ) { value = super.generateHolder( session ); } return value.makeValue(); } return hiloOptimizer.generate( new AccessCallback() { public IntegralDataTypeHolder getNextValue() { return generateHolder( session ); } } ); } }
SequenceHiLoGenerator extends SequenceGenerator { public synchronized Serializable generate(final SessionImplementor session, Object obj) { if ( maxLo < 1 ) { IntegralDataTypeHolder value = null; while ( value == null || value.lt( 0 ) ) { value = super.generateHolder( session ); } return value.makeValue(); } return hiloOptimizer.generate( new AccessCallback() { public IntegralDataTypeHolder getNextValue() { return generateHolder( session ); } } ); }  }
SequenceHiLoGenerator extends SequenceGenerator { public synchronized Serializable generate(final SessionImplementor session, Object obj) { if ( maxLo < 1 ) { IntegralDataTypeHolder value = null; while ( value == null || value.lt( 0 ) ) { value = super.generateHolder( session ); } return value.makeValue(); } return hiloOptimizer.generate( new AccessCallback() { public IntegralDataTypeHolder getNextValue() { return generateHolder( session ); } } ); }  void configure(Type type, Properties params, Dialect d); synchronized Serializable generate(final SessionImplementor session, Object obj); }
SequenceHiLoGenerator extends SequenceGenerator { public synchronized Serializable generate(final SessionImplementor session, Object obj) { if ( maxLo < 1 ) { IntegralDataTypeHolder value = null; while ( value == null || value.lt( 0 ) ) { value = super.generateHolder( session ); } return value.makeValue(); } return hiloOptimizer.generate( new AccessCallback() { public IntegralDataTypeHolder getNextValue() { return generateHolder( session ); } } ); }  void configure(Type type, Properties params, Dialect d); synchronized Serializable generate(final SessionImplementor session, Object obj); static final String MAX_LO; }