use of jakarta.persistence.TableGenerators in project hibernate-orm by hibernate.
the class AnnotationBinder method bindPackage.
public static void bindPackage(ClassLoaderService cls, String packageName, MetadataBuildingContext context) {
final Package packaze = cls.packageForNameOrNull(packageName);
if (packaze == null) {
return;
}
final XPackage pckg = context.getBootstrapContext().getReflectionManager().toXPackage(packaze);
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));
}
}
handleTypeDescriptorRegistrations(pckg, context);
bindEmbeddableInstantiatorRegistrations(pckg, context);
bindCompositeUserTypeRegistrations(pckg, context);
bindGenericGenerators(pckg, context);
bindQueries(pckg, context);
bindFilterDefs(pckg, context);
}
use of jakarta.persistence.TableGenerators in project hibernate-orm by hibernate.
the class AnnotationBinder method buildGenerators.
private static HashMap<String, IdentifierGeneratorDefinition> buildGenerators(XAnnotatedElement annElt, MetadataBuildingContext context) {
InFlightMetadataCollector metadataCollector = context.getMetadataCollector();
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);
metadataCollector.addIdentifierGenerator(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);
metadataCollector.addIdentifierGenerator(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);
metadataCollector.addIdentifierGenerator(idGen);
}
if (seqGen != null) {
IdentifierGeneratorDefinition idGen = buildIdGenerator(seqGen, context);
generators.put(idGen.getName(), idGen);
metadataCollector.addIdentifierGenerator(idGen);
}
if (genGen != null) {
IdentifierGeneratorDefinition idGen = buildIdGenerator(genGen, context);
generators.put(idGen.getName(), idGen);
metadataCollector.addIdentifierGenerator(idGen);
}
return generators;
}
Aggregations