HHH-18127 - Leverage hibernate-models Annotation-as-Class

This commit is contained in:
Andrea Boriero 2024-07-25 11:49:34 +02:00 committed by Steve Ebersole
parent 611844fe79
commit 5ff2768510
2 changed files with 9 additions and 2 deletions

View File

@ -10,6 +10,7 @@ import java.lang.annotation.Annotation;
import org.hibernate.annotations.UuidGenerator;
import org.hibernate.boot.models.HibernateAnnotations;
import org.hibernate.id.uuid.UuidValueGenerator;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
@ -20,12 +21,14 @@ import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJand
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class UuidGeneratorAnnotation implements UuidGenerator {
private org.hibernate.annotations.UuidGenerator.Style style;
private Class<? extends UuidValueGenerator> algorithm;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public UuidGeneratorAnnotation(SourceModelBuildingContext modelContext) {
this.style = org.hibernate.annotations.UuidGenerator.Style.AUTO;
this.algorithm = UuidValueGenerator.class;
}
/**
@ -33,6 +36,7 @@ public class UuidGeneratorAnnotation implements UuidGenerator {
*/
public UuidGeneratorAnnotation(UuidGenerator annotation, SourceModelBuildingContext modelContext) {
this.style = annotation.style();
this.algorithm = annotation.algorithm();
}
/**
@ -52,9 +56,13 @@ public class UuidGeneratorAnnotation implements UuidGenerator {
return style;
}
@Override
public Class<? extends UuidValueGenerator> algorithm() {
return algorithm;
}
public void style(org.hibernate.annotations.UuidGenerator.Style value) {
this.style = value;
}
}

View File

@ -215,7 +215,6 @@ import org.hibernate.persister.entity.mutation.UpdateCoordinator;
import org.hibernate.persister.entity.mutation.UpdateCoordinatorNoOp;
import org.hibernate.persister.entity.mutation.UpdateCoordinatorStandard;
import org.hibernate.persister.internal.SqlFragmentPredicate;
import org.hibernate.persister.spi.PersisterCreationContext;
import org.hibernate.property.access.spi.Getter;
import org.hibernate.property.access.spi.PropertyAccess;
import org.hibernate.property.access.spi.Setter;