public class GeneratedValueProcessor
{
public void process(Class<?> clazz, Field idField, EntityMetadata m,
Map<String, IdDiscriptor> entityNameToKeyDiscriptorMap)
{
IdDiscriptor keyValue = new IdDiscriptor();
GeneratedValue value = idField.getAnnotation(GeneratedValue.class);
String generatorName = value.generator();
GenerationType generationType = value.strategy();
switch (generationType)
{
case TABLE:
TableGeneratorDiscriptor tgd = processTableGenerator(clazz, idField, m, generatorName);
keyValue.setTableDiscriptor(tgd);
keyValue.setStrategy(GenerationType.TABLE);
break;
case SEQUENCE:
SequenceGeneratorDiscriptor sgd = processSequenceGenerator(clazz, idField, m, generatorName);
keyValue.setSequenceDiscriptor(sgd);
keyValue.setStrategy(GenerationType.SEQUENCE);
break;
case IDENTITY:
keyValue.setStrategy(GenerationType.IDENTITY);
break;
case AUTO:
// No need of Any Generator
keyValue.setStrategy(GenerationType.AUTO);
break;
}
entityNameToKeyDiscriptorMap.put(clazz.getName(), keyValue);
}