HHH-6501 Pushing custom tuplizer into ConfiguredClass
This commit is contained in:
parent
b1478946db
commit
6fb38e45ae
|
@ -44,7 +44,6 @@ import org.jboss.jandex.MethodInfo;
|
|||
import org.jboss.jandex.Type;
|
||||
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
|
||||
|
@ -364,25 +363,4 @@ public class JandexHelper {
|
|||
|
||||
return type.cast( returnValue );
|
||||
}
|
||||
|
||||
public static AnnotationInstance locatePojoTuplizerAnnotation(ClassInfo classInfo) {
|
||||
final AnnotationInstance tuplizersAnnotation = getSingleAnnotation(
|
||||
classInfo, HibernateDotNames.TUPLIZERS
|
||||
);
|
||||
if ( tuplizersAnnotation == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
AnnotationInstance[] annotations = getValue(
|
||||
tuplizersAnnotation,
|
||||
"value",
|
||||
AnnotationInstance[].class
|
||||
);
|
||||
for ( AnnotationInstance tuplizerAnnotation : annotations ) {
|
||||
if ( EntityMode.valueOf( tuplizerAnnotation.value( "entityModeType" ).asEnum() ) == EntityMode.POJO ) {
|
||||
return tuplizerAnnotation;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,12 +105,7 @@ public class ComponentAttributeSourceImpl implements ComponentAttributeSource {
|
|||
|
||||
@Override
|
||||
public String getExplicitTuplizerClassName() {
|
||||
String customTuplizer = null;
|
||||
final AnnotationInstance pojoTuplizerAnnotation = JandexHelper.locatePojoTuplizerAnnotation( embeddableClass.getClassInfo() );
|
||||
if ( pojoTuplizerAnnotation != null ) {
|
||||
customTuplizer = pojoTuplizerAnnotation.value( "impl" ).asString();
|
||||
}
|
||||
return customTuplizer;
|
||||
return embeddableClass.getCustomTuplizer();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -51,10 +51,12 @@ import org.jboss.logging.Logger;
|
|||
|
||||
import org.hibernate.AnnotationException;
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.cfg.NotYetImplementedException;
|
||||
import org.hibernate.metamodel.source.MappingException;
|
||||
import org.hibernate.metamodel.source.annotations.AnnotationBindingContext;
|
||||
import org.hibernate.metamodel.source.annotations.HibernateDotNames;
|
||||
import org.hibernate.metamodel.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.source.annotations.JandexHelper;
|
||||
import org.hibernate.metamodel.source.annotations.ReflectionHelper;
|
||||
|
@ -130,6 +132,11 @@ public class ConfiguredClass {
|
|||
private final Set<String> transientFieldNames = new HashSet<String>();
|
||||
private final Set<String> transientMethodNames = new HashSet<String>();
|
||||
|
||||
/**
|
||||
* Fully qualified name of a custom tuplizer
|
||||
*/
|
||||
private final String customTuplizer;
|
||||
|
||||
private final LocalBindingContextImpl localBindingContext;
|
||||
|
||||
public ConfiguredClass(
|
||||
|
@ -142,6 +149,8 @@ public class ConfiguredClass {
|
|||
this.clazz = context.locateClassByName( classInfo.toString() );
|
||||
this.configuredClassType = determineType();
|
||||
this.classAccessType = determineClassAccessType( defaultAccessType );
|
||||
this.customTuplizer = determineCustomTuplizer();
|
||||
|
||||
this.simpleAttributeMap = new TreeMap<String, BasicAttribute>();
|
||||
this.idAttributeMap = new TreeMap<String, BasicAttribute>();
|
||||
this.associationAttributeMap = new TreeMap<String, AssociationAttribute>();
|
||||
|
@ -204,6 +213,10 @@ public class ConfiguredClass {
|
|||
return classAccessType;
|
||||
}
|
||||
|
||||
public String getCustomTuplizer() {
|
||||
return customTuplizer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
@ -658,4 +671,33 @@ public class ConfiguredClass {
|
|||
|
||||
return associationOverrideList;
|
||||
}
|
||||
|
||||
private String determineCustomTuplizer() {
|
||||
final AnnotationInstance tuplizersAnnotation = JandexHelper.getSingleAnnotation(
|
||||
classInfo, HibernateDotNames.TUPLIZERS
|
||||
);
|
||||
if ( tuplizersAnnotation == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
AnnotationInstance[] annotations = JandexHelper.getValue(
|
||||
tuplizersAnnotation,
|
||||
"value",
|
||||
AnnotationInstance[].class
|
||||
);
|
||||
|
||||
AnnotationInstance pojoTuplizerAnnotation = null;
|
||||
for ( AnnotationInstance tuplizerAnnotation : annotations ) {
|
||||
if ( EntityMode.valueOf( tuplizerAnnotation.value( "entityModeType" ).asEnum() ) == EntityMode.POJO ) {
|
||||
pojoTuplizerAnnotation = tuplizerAnnotation;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
String customTuplizer = null;
|
||||
if ( pojoTuplizerAnnotation != null ) {
|
||||
customTuplizer = pojoTuplizerAnnotation.value( "impl" ).asString();
|
||||
}
|
||||
return customTuplizer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,6 @@ public class EntityClass extends ConfiguredClass {
|
|||
private final String explicitEntityName;
|
||||
private final String customLoaderQueryName;
|
||||
private final List<String> synchronizedTableNames;
|
||||
private final String customTuplizer;
|
||||
private final int batchSize;
|
||||
|
||||
private final TableSource primaryTableSource;
|
||||
|
@ -130,7 +129,6 @@ public class EntityClass extends ConfiguredClass {
|
|||
this.secondaryTableSources = createSecondaryTableSources();
|
||||
this.customLoaderQueryName = determineCustomLoader();
|
||||
this.synchronizedTableNames = determineSynchronizedTableNames();
|
||||
this.customTuplizer = determineCustomTuplizer();
|
||||
this.batchSize = determineBatchSize();
|
||||
|
||||
processHibernateEntitySpecificAnnotations();
|
||||
|
@ -241,10 +239,6 @@ public class EntityClass extends ConfiguredClass {
|
|||
return customPersister;
|
||||
}
|
||||
|
||||
public String getCustomTuplizer() {
|
||||
return customTuplizer;
|
||||
}
|
||||
|
||||
public boolean isLazy() {
|
||||
return isLazy;
|
||||
}
|
||||
|
@ -716,16 +710,6 @@ public class EntityClass extends ConfiguredClass {
|
|||
}
|
||||
}
|
||||
|
||||
private String determineCustomTuplizer() {
|
||||
// Custom tuplizer
|
||||
String customTuplizer = null;
|
||||
final AnnotationInstance pojoTuplizerAnnotation = JandexHelper.locatePojoTuplizerAnnotation( getClassInfo() );
|
||||
if ( pojoTuplizerAnnotation != null ) {
|
||||
customTuplizer = pojoTuplizerAnnotation.value( "impl" ).asString();
|
||||
}
|
||||
return customTuplizer;
|
||||
}
|
||||
|
||||
private void processProxyGeneration() {
|
||||
// Proxy generation
|
||||
final AnnotationInstance hibernateProxyAnnotation = JandexHelper.getSingleAnnotation(
|
||||
|
|
Loading…
Reference in New Issue