use of javax.persistence.TableGenerators in project hibernate-orm by hibernate.
the class AnnotationBinder method bindPackage.
public static void bindPackage(String packageName, MetadataBuildingContext context) {
XPackage pckg;
try {
pckg = context.getBootstrapContext().getReflectionManager().packageForName(packageName);
} catch (ClassLoadingException e) {
LOG.packageNotFound(packageName);
return;
} catch (ClassNotFoundException cnf) {
LOG.packageNotFound(packageName);
return;
}
if (pckg.isAnnotationPresent(SequenceGenerator.class)) {
SequenceGenerator ann = pckg.getAnnotation(SequenceGenerator.class);
IdentifierGeneratorDefinition idGen = buildIdGenerator(ann, context);
context.getMetadataCollector().addIdentifierGenerator(idGen);
if (LOG.isTraceEnabled()) {
LOG.tracev("Add sequence generator with name: {0}", idGen.getName());
}
}
if (pckg.isAnnotationPresent(SequenceGenerators.class)) {
SequenceGenerators ann = pckg.getAnnotation(SequenceGenerators.class);
for (SequenceGenerator tableGenerator : ann.value()) {
context.getMetadataCollector().addIdentifierGenerator(buildIdGenerator(tableGenerator, context));
}
}
if (pckg.isAnnotationPresent(TableGenerator.class)) {
TableGenerator ann = pckg.getAnnotation(TableGenerator.class);
IdentifierGeneratorDefinition idGen = buildIdGenerator(ann, context);
context.getMetadataCollector().addIdentifierGenerator(idGen);
}
if (pckg.isAnnotationPresent(TableGenerators.class)) {
TableGenerators ann = pckg.getAnnotation(TableGenerators.class);
for (TableGenerator tableGenerator : ann.value()) {
context.getMetadataCollector().addIdentifierGenerator(buildIdGenerator(tableGenerator, context));
}
}
bindGenericGenerators(pckg, context);
bindQueries(pckg, context);
bindFilterDefs(pckg, context);
bindTypeDefs(pckg, context);
bindFetchProfiles(pckg, context);
BinderHelper.bindAnyMetaDefs(pckg, context);
}
use of javax.persistence.TableGenerators in project hibernate-orm by hibernate.
the class AnnotationBinder method buildGenerators.
private static HashMap<String, IdentifierGeneratorDefinition> buildGenerators(XAnnotatedElement annElt, MetadataBuildingContext context) {
HashMap<String, IdentifierGeneratorDefinition> generators = new HashMap<>();
TableGenerators tableGenerators = annElt.getAnnotation(TableGenerators.class);
if (tableGenerators != null) {
for (TableGenerator tableGenerator : tableGenerators.value()) {
IdentifierGeneratorDefinition idGenerator = buildIdGenerator(tableGenerator, context);
generators.put(idGenerator.getName(), idGenerator);
}
}
SequenceGenerators sequenceGenerators = annElt.getAnnotation(SequenceGenerators.class);
if (sequenceGenerators != null) {
for (SequenceGenerator sequenceGenerator : sequenceGenerators.value()) {
IdentifierGeneratorDefinition idGenerator = buildIdGenerator(sequenceGenerator, context);
generators.put(idGenerator.getName(), idGenerator);
}
}
TableGenerator tabGen = annElt.getAnnotation(TableGenerator.class);
SequenceGenerator seqGen = annElt.getAnnotation(SequenceGenerator.class);
GenericGenerator genGen = annElt.getAnnotation(GenericGenerator.class);
if (tabGen != null) {
IdentifierGeneratorDefinition idGen = buildIdGenerator(tabGen, context);
generators.put(idGen.getName(), idGen);
}
if (seqGen != null) {
IdentifierGeneratorDefinition idGen = buildIdGenerator(seqGen, context);
generators.put(idGen.getName(), idGen);
}
if (genGen != null) {
IdentifierGeneratorDefinition idGen = buildIdGenerator(genGen, context);
generators.put(idGen.getName(), idGen);
}
generators.forEach((name, idGenerator) -> {
context.getMetadataCollector().addIdentifierGenerator(idGenerator);
});
return generators;
}
Aggregations