Do some research (looking at Hibernate sources):
AnnotationBinder defines how AUTO is displayed:
switch ( generatorEnum ) { // ... case AUTO: return useNewGeneratorMappings ? org.hibernate.id.enhanced.SequenceStyleGenerator.class.getName() : "native"; // ...
If you are not using NewGeneratorMappings, you are stuck in your own implementation. Hibernate will decide which one depending on the database (see this answer to find out what will be for your specific database).
But since you used NewGeneratorMappings, we should look at SequenceStyleGenerator :
protected String determineOptimizationStrategy(Properties params, int incrementSize) {
Assuming the correct properties are passed, and you have the optimizer property, then your value should be returned. This value is used to call OptimizerFactory.buildOptimizer (as the first parameter):
public static Optimizer buildOptimizer(String type, Class returnClass, int incrementSize) { final Class<? extends Optimizer> optimizerClass; final StandardOptimizerDescriptor standardDescriptor = StandardOptimizerDescriptor.fromExternalName( type ); // HILO("hilo", HiLoOptimizer.class), if ( standardDescriptor != null ) { optimizerClass = standardDescriptor.getOptimizerClass(); } else { try { optimizerClass = ReflectHelper.classForName( type ); } catch( Throwable ignore ) { LOG.unableToLocateCustomOptimizerClass( type ); return buildFallbackOptimizer( returnClass, incrementSize ); } } try { final Constructor ctor = optimizerClass.getConstructor( CTOR_SIG ); return (Optimizer) ctor.newInstance( returnClass, incrementSize ); } catch( Throwable ignore ) { LOG.unableToInstantiateOptimizer( type ); } return buildFallbackOptimizer( returnClass, incrementSize ); } private static Optimizer buildFallbackOptimizer(Class returnClass, int incrementSize) { return new NoopOptimizer( returnClass, incrementSize ); }
That way, either it finds your hilo value (or your HiLoOptimizer), creates an instance and returns it, or it logs some error message. If an error message does not appear in your logs, I would check if the properties in cfg.xml are actually used . Try to access them using getProperties() on your instance of org.hibernate.internal.SessionFactoryImpl .
xwoker Nov 09 '13 at 19:08 2013-11-09 19:08
source share