HHH-14290 Remove capability of loading classes by name from HCANN
This commit is contained in:
parent
a0e4ab72ec
commit
503c48cbc7
|
@ -13,11 +13,8 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.AssertionFailure;
|
import org.hibernate.AssertionFailure;
|
||||||
import org.hibernate.annotations.common.reflection.ClassLoaderDelegate;
|
|
||||||
import org.hibernate.annotations.common.reflection.ClassLoadingException;
|
|
||||||
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
||||||
import org.hibernate.annotations.common.reflection.java.JavaReflectionManager;
|
import org.hibernate.annotations.common.reflection.java.JavaReflectionManager;
|
||||||
import org.hibernate.annotations.common.util.StandardClassLoaderDelegateImpl;
|
|
||||||
import org.hibernate.boot.AttributeConverterInfo;
|
import org.hibernate.boot.AttributeConverterInfo;
|
||||||
import org.hibernate.boot.CacheRegionDefinition;
|
import org.hibernate.boot.CacheRegionDefinition;
|
||||||
import org.hibernate.boot.archive.scan.internal.StandardScanOptions;
|
import org.hibernate.boot.archive.scan.internal.StandardScanOptions;
|
||||||
|
@ -313,32 +310,7 @@ public class BootstrapContextImpl implements BootstrapContext {
|
||||||
private JavaReflectionManager generateHcannReflectionManager() {
|
private JavaReflectionManager generateHcannReflectionManager() {
|
||||||
final JavaReflectionManager reflectionManager = new JavaReflectionManager();
|
final JavaReflectionManager reflectionManager = new JavaReflectionManager();
|
||||||
reflectionManager.setMetadataProvider( new JPAMetadataProvider( this ) );
|
reflectionManager.setMetadataProvider( new JPAMetadataProvider( this ) );
|
||||||
reflectionManager.injectClassLoaderDelegate( generateHcannClassLoaderDelegate() );
|
|
||||||
return reflectionManager;
|
return reflectionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClassLoaderDelegate generateHcannClassLoaderDelegate() {
|
|
||||||
// class loading here needs to be drastically different for 7.0
|
|
||||||
// but luckily 7.0 will do away with HCANN use and be easier to
|
|
||||||
// implement this.
|
|
||||||
//
|
|
||||||
// todo (6.0) : *if possible* make similar change in 6.0
|
|
||||||
// possibly using the JPA temp class loader or create our own "throw awy" ClassLoader;
|
|
||||||
// the trouble there is that we eventually need to load the Class into the real
|
|
||||||
// ClassLoader prior to use
|
|
||||||
|
|
||||||
final ClassLoaderService classLoaderService = getServiceRegistry().getService( ClassLoaderService.class );
|
|
||||||
|
|
||||||
return new ClassLoaderDelegate() {
|
|
||||||
@Override
|
|
||||||
public <T> Class<T> classForName(String className) throws ClassLoadingException {
|
|
||||||
try {
|
|
||||||
return classLoaderService.classForName( className );
|
|
||||||
}
|
|
||||||
catch (org.hibernate.boot.registry.classloading.spi.ClassLoadingException e) {
|
|
||||||
return StandardClassLoaderDelegateImpl.INSTANCE.classForName( className );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,6 @@ import javax.persistence.Embeddable;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
|
|
||||||
import org.hibernate.AnnotationException;
|
|
||||||
import org.hibernate.annotations.common.reflection.ClassLoadingException;
|
|
||||||
import org.hibernate.annotations.common.reflection.MetadataProviderInjector;
|
import org.hibernate.annotations.common.reflection.MetadataProviderInjector;
|
||||||
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
||||||
import org.hibernate.annotations.common.reflection.XClass;
|
import org.hibernate.annotations.common.reflection.XClass;
|
||||||
|
@ -59,6 +57,7 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
|
||||||
private final LinkedHashSet<String> annotatedPackages = new LinkedHashSet<String>();
|
private final LinkedHashSet<String> annotatedPackages = new LinkedHashSet<String>();
|
||||||
|
|
||||||
private final List<XClass> xClasses = new ArrayList<XClass>();
|
private final List<XClass> xClasses = new ArrayList<XClass>();
|
||||||
|
private final ClassLoaderService classLoaderService;
|
||||||
|
|
||||||
public AnnotationMetadataSourceProcessorImpl(
|
public AnnotationMetadataSourceProcessorImpl(
|
||||||
ManagedResources managedResources,
|
ManagedResources managedResources,
|
||||||
|
@ -74,6 +73,7 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
|
||||||
}
|
}
|
||||||
|
|
||||||
final AttributeConverterManager attributeConverterManager = new AttributeConverterManager( rootMetadataBuildingContext );
|
final AttributeConverterManager attributeConverterManager = new AttributeConverterManager( rootMetadataBuildingContext );
|
||||||
|
this.classLoaderService = rootMetadataBuildingContext.getBuildingOptions().getServiceRegistry().getService( ClassLoaderService.class );
|
||||||
|
|
||||||
if ( rootMetadataBuildingContext.getBuildingOptions().isXmlMappingEnabled() ) {
|
if ( rootMetadataBuildingContext.getBuildingOptions().isXmlMappingEnabled() ) {
|
||||||
|
|
||||||
|
@ -97,25 +97,24 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
|
||||||
|
|
||||||
final List<String> classNames = jpaMetadataProvider.getXMLContext().addDocument( dom4jDocument );
|
final List<String> classNames = jpaMetadataProvider.getXMLContext().addDocument( dom4jDocument );
|
||||||
for ( String className : classNames ) {
|
for ( String className : classNames ) {
|
||||||
xClasses.add( toXClass( className, reflectionManager ) );
|
xClasses.add( toXClass( className, reflectionManager, classLoaderService ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jpaMetadataProvider.getXMLContext().applyDiscoveredAttributeConverters( attributeConverterManager );
|
jpaMetadataProvider.getXMLContext().applyDiscoveredAttributeConverters( attributeConverterManager );
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
}
|
}
|
||||||
|
|
||||||
final ClassLoaderService cls = rootMetadataBuildingContext.getBuildingOptions().getServiceRegistry().getService( ClassLoaderService.class );
|
|
||||||
for ( String className : managedResources.getAnnotatedClassNames() ) {
|
for ( String className : managedResources.getAnnotatedClassNames() ) {
|
||||||
final Class annotatedClass = cls.classForName( className );
|
final Class annotatedClass = classLoaderService.classForName( className );
|
||||||
categorizeAnnotatedClass( annotatedClass, attributeConverterManager );
|
categorizeAnnotatedClass( annotatedClass, attributeConverterManager, classLoaderService );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( Class annotatedClass : managedResources.getAnnotatedClassReferences() ) {
|
for ( Class annotatedClass : managedResources.getAnnotatedClassReferences() ) {
|
||||||
categorizeAnnotatedClass( annotatedClass, attributeConverterManager );
|
categorizeAnnotatedClass( annotatedClass, attributeConverterManager, classLoaderService );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void categorizeAnnotatedClass(Class annotatedClass, AttributeConverterManager attributeConverterManager) {
|
private void categorizeAnnotatedClass(Class annotatedClass, AttributeConverterManager attributeConverterManager, ClassLoaderService cls) {
|
||||||
final XClass xClass = reflectionManager.toXClass( annotatedClass );
|
final XClass xClass = reflectionManager.toXClass( annotatedClass );
|
||||||
// categorize it, based on assumption it does not fall into multiple categories
|
// categorize it, based on assumption it does not fall into multiple categories
|
||||||
if ( xClass.isAnnotationPresent( Converter.class ) ) {
|
if ( xClass.isAnnotationPresent( Converter.class ) ) {
|
||||||
|
@ -135,13 +134,8 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private XClass toXClass(String className, ReflectionManager reflectionManager) {
|
private XClass toXClass(String className, ReflectionManager reflectionManager, ClassLoaderService cls) {
|
||||||
try {
|
return reflectionManager.toXClass( cls.classForName( className ) );
|
||||||
return reflectionManager.classForName( className );
|
|
||||||
}
|
|
||||||
catch ( ClassLoadingException e ) {
|
|
||||||
throw new AnnotationException( "Unable to load class defined in XML: " + className, e );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private Document toDom4jDocument(MappingBinder.DelayedOrmXmlData delayedOrmXmlData) {
|
// private Document toDom4jDocument(MappingBinder.DelayedOrmXmlData delayedOrmXmlData) {
|
||||||
|
@ -192,7 +186,7 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
|
||||||
|
|
||||||
AnnotationBinder.bindDefaults( rootMetadataBuildingContext );
|
AnnotationBinder.bindDefaults( rootMetadataBuildingContext );
|
||||||
for ( String annotatedPackage : annotatedPackages ) {
|
for ( String annotatedPackage : annotatedPackages ) {
|
||||||
AnnotationBinder.bindPackage( annotatedPackage, rootMetadataBuildingContext );
|
AnnotationBinder.bindPackage( classLoaderService, annotatedPackage, rootMetadataBuildingContext );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,7 +297,7 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
|
||||||
@Override
|
@Override
|
||||||
public void postProcessEntityHierarchies() {
|
public void postProcessEntityHierarchies() {
|
||||||
for ( String annotatedPackage : annotatedPackages ) {
|
for ( String annotatedPackage : annotatedPackages ) {
|
||||||
AnnotationBinder.bindFetchProfilesForPackage( annotatedPackage, rootMetadataBuildingContext );
|
AnnotationBinder.bindFetchProfilesForPackage( classLoaderService, annotatedPackage, rootMetadataBuildingContext );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -261,6 +261,22 @@ public class ClassLoaderServiceImpl implements ClassLoaderService {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Package packageForNameOrNull(String packageName) {
|
||||||
|
try {
|
||||||
|
Class<?> aClass = Class.forName( packageName + ".package-info", true, getAggregatedClassLoader() );
|
||||||
|
return aClass == null ? null : aClass.getPackage();
|
||||||
|
}
|
||||||
|
catch (ClassNotFoundException e) {
|
||||||
|
log.packageNotFound( packageName );
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch (LinkageError e) {
|
||||||
|
log.warn( "LinkageError while attempting to load Package named " + packageName, e );
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T workWithClassLoader(Work<T> work) {
|
public <T> T workWithClassLoader(Work<T> work) {
|
||||||
return work.doWork( getAggregatedClassLoader() );
|
return work.doWork( getAggregatedClassLoader() );
|
||||||
|
|
|
@ -75,6 +75,21 @@ public interface ClassLoaderService extends Service, Stoppable {
|
||||||
|
|
||||||
<T> T generateProxy(InvocationHandler handler, Class... interfaces);
|
<T> T generateProxy(InvocationHandler handler, Class... interfaces);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loading a Package from the classloader. In case it's not found or an
|
||||||
|
* internal error (such as @see {@link LinkageError} occurs, we
|
||||||
|
* return null rather than throwing an exception.
|
||||||
|
* This is significantly different than loading a Class, as in all
|
||||||
|
* currently known usages, being unable to load the Package will
|
||||||
|
* only result in ignoring annotations on it - which is totally
|
||||||
|
* fine when the object doesn't exist.
|
||||||
|
* In case of other errors, implementations are expected to log
|
||||||
|
* a warning but it's still not treated as a fatal error.
|
||||||
|
* @param packageName
|
||||||
|
* @return the matching Package, or null.
|
||||||
|
*/
|
||||||
|
Package packageForNameOrNull(String packageName);
|
||||||
|
|
||||||
interface Work<T> {
|
interface Work<T> {
|
||||||
T doWork(ClassLoader classLoader);
|
T doWork(ClassLoader classLoader);
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ import org.hibernate.annotations.Tuplizers;
|
||||||
import org.hibernate.annotations.TypeDef;
|
import org.hibernate.annotations.TypeDef;
|
||||||
import org.hibernate.annotations.TypeDefs;
|
import org.hibernate.annotations.TypeDefs;
|
||||||
import org.hibernate.annotations.Where;
|
import org.hibernate.annotations.Where;
|
||||||
import org.hibernate.annotations.common.reflection.ClassLoadingException;
|
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
||||||
import org.hibernate.annotations.common.reflection.XAnnotatedElement;
|
import org.hibernate.annotations.common.reflection.XAnnotatedElement;
|
||||||
import org.hibernate.annotations.common.reflection.XClass;
|
import org.hibernate.annotations.common.reflection.XClass;
|
||||||
import org.hibernate.annotations.common.reflection.XMethod;
|
import org.hibernate.annotations.common.reflection.XMethod;
|
||||||
|
@ -132,6 +132,7 @@ import org.hibernate.annotations.common.reflection.XProperty;
|
||||||
import org.hibernate.boot.model.IdGeneratorStrategyInterpreter;
|
import org.hibernate.boot.model.IdGeneratorStrategyInterpreter;
|
||||||
import org.hibernate.boot.model.IdentifierGeneratorDefinition;
|
import org.hibernate.boot.model.IdentifierGeneratorDefinition;
|
||||||
import org.hibernate.boot.model.TypeDefinition;
|
import org.hibernate.boot.model.TypeDefinition;
|
||||||
|
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||||
import org.hibernate.boot.spi.InFlightMetadataCollector;
|
import org.hibernate.boot.spi.InFlightMetadataCollector;
|
||||||
import org.hibernate.boot.spi.InFlightMetadataCollector.EntityTableXref;
|
import org.hibernate.boot.spi.InFlightMetadataCollector.EntityTableXref;
|
||||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
|
@ -146,8 +147,6 @@ import org.hibernate.cfg.annotations.QueryBinder;
|
||||||
import org.hibernate.cfg.annotations.SimpleValueBinder;
|
import org.hibernate.cfg.annotations.SimpleValueBinder;
|
||||||
import org.hibernate.cfg.annotations.TableBinder;
|
import org.hibernate.cfg.annotations.TableBinder;
|
||||||
import org.hibernate.engine.OptimisticLockStyle;
|
import org.hibernate.engine.OptimisticLockStyle;
|
||||||
import org.hibernate.engine.config.spi.ConfigurationService;
|
|
||||||
import org.hibernate.engine.config.spi.StandardConverters;
|
|
||||||
import org.hibernate.engine.spi.FilterDefinition;
|
import org.hibernate.engine.spi.FilterDefinition;
|
||||||
import org.hibernate.id.PersistentIdentifierGenerator;
|
import org.hibernate.id.PersistentIdentifierGenerator;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
|
@ -306,19 +305,12 @@ public final class AnnotationBinder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void bindPackage(String packageName, MetadataBuildingContext context) {
|
public static void bindPackage(ClassLoaderService cls, String packageName, MetadataBuildingContext context) {
|
||||||
XPackage pckg;
|
final Package packaze = cls.packageForNameOrNull( packageName );
|
||||||
try {
|
if ( packaze == null ) {
|
||||||
pckg = context.getBootstrapContext().getReflectionManager().packageForName( packageName );
|
|
||||||
}
|
|
||||||
catch (ClassLoadingException e) {
|
|
||||||
LOG.packageNotFound( packageName );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
catch ( ClassNotFoundException cnf ) {
|
|
||||||
LOG.packageNotFound( packageName );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
final XPackage pckg = context.getBootstrapContext().getReflectionManager().toXPackage( packaze );
|
||||||
|
|
||||||
if ( pckg.isAnnotationPresent( SequenceGenerator.class ) ) {
|
if ( pckg.isAnnotationPresent( SequenceGenerator.class ) ) {
|
||||||
SequenceGenerator ann = pckg.getAnnotation( SequenceGenerator.class );
|
SequenceGenerator ann = pckg.getAnnotation( SequenceGenerator.class );
|
||||||
|
@ -1423,20 +1415,13 @@ public final class AnnotationBinder {
|
||||||
bindFetchProfiles( clazzToProcess, context );
|
bindFetchProfiles( clazzToProcess, context );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void bindFetchProfilesForPackage(String packageName, MetadataBuildingContext context) {
|
public static void bindFetchProfilesForPackage(ClassLoaderService cls, String packageName, MetadataBuildingContext context) {
|
||||||
XPackage pckg;
|
final Package packaze = cls.packageForNameOrNull( packageName );
|
||||||
try {
|
if ( packaze == null ) {
|
||||||
pckg = context.getBootstrapContext().getReflectionManager().packageForName( packageName );
|
|
||||||
}
|
|
||||||
catch (ClassLoadingException e) {
|
|
||||||
LOG.packageNotFound( packageName );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch ( ClassNotFoundException cnf ) {
|
final ReflectionManager reflectionManager = context.getBootstrapContext().getReflectionManager();
|
||||||
LOG.packageNotFound( packageName );
|
final XPackage pckg = reflectionManager.toXPackage( packaze );
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bindFetchProfiles( pckg, context );
|
bindFetchProfiles( pckg, context );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ import org.hibernate.annotations.AnyMetaDef;
|
||||||
import org.hibernate.annotations.AnyMetaDefs;
|
import org.hibernate.annotations.AnyMetaDefs;
|
||||||
import org.hibernate.annotations.MetaValue;
|
import org.hibernate.annotations.MetaValue;
|
||||||
import org.hibernate.annotations.SqlFragmentAlias;
|
import org.hibernate.annotations.SqlFragmentAlias;
|
||||||
import org.hibernate.annotations.common.reflection.ClassLoadingException;
|
|
||||||
import org.hibernate.annotations.common.reflection.XAnnotatedElement;
|
import org.hibernate.annotations.common.reflection.XAnnotatedElement;
|
||||||
import org.hibernate.annotations.common.reflection.XClass;
|
import org.hibernate.annotations.common.reflection.XClass;
|
||||||
import org.hibernate.annotations.common.reflection.XPackage;
|
import org.hibernate.annotations.common.reflection.XPackage;
|
||||||
|
@ -1097,14 +1096,8 @@ public class BinderHelper {
|
||||||
PropertyHolder propertyHolder,
|
PropertyHolder propertyHolder,
|
||||||
String propertyName,
|
String propertyName,
|
||||||
MetadataBuildingContext buildingContext) {
|
MetadataBuildingContext buildingContext) {
|
||||||
final XClass persistentXClass;
|
final XClass persistentXClass = buildingContext.getBootstrapContext().getReflectionManager()
|
||||||
try {
|
.toXClass( propertyHolder.getPersistentClass().getMappedClass() );
|
||||||
persistentXClass = buildingContext.getBootstrapContext().getReflectionManager()
|
|
||||||
.classForName( propertyHolder.getPersistentClass().getClassName() );
|
|
||||||
}
|
|
||||||
catch ( ClassLoadingException e ) {
|
|
||||||
throw new AssertionFailure( "PersistentClass name cannot be converted into a Class", e);
|
|
||||||
}
|
|
||||||
if ( propertyHolder.isInIdClass() ) {
|
if ( propertyHolder.isInIdClass() ) {
|
||||||
PropertyData pd = buildingContext.getMetadataCollector().getPropertyAnnotatedWithIdAndToOne(
|
PropertyData pd = buildingContext.getMetadataCollector().getPropertyAnnotatedWithIdAndToOne(
|
||||||
persistentXClass,
|
persistentXClass,
|
||||||
|
|
|
@ -23,9 +23,9 @@ import org.hibernate.AnnotationException;
|
||||||
import org.hibernate.AssertionFailure;
|
import org.hibernate.AssertionFailure;
|
||||||
import org.hibernate.FetchMode;
|
import org.hibernate.FetchMode;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.annotations.common.reflection.ClassLoadingException;
|
|
||||||
import org.hibernate.annotations.common.reflection.XClass;
|
import org.hibernate.annotations.common.reflection.XClass;
|
||||||
import org.hibernate.annotations.common.reflection.XProperty;
|
import org.hibernate.annotations.common.reflection.XProperty;
|
||||||
|
import org.hibernate.boot.spi.BootstrapContext;
|
||||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
import org.hibernate.cfg.AccessType;
|
import org.hibernate.cfg.AccessType;
|
||||||
import org.hibernate.cfg.AnnotatedClassType;
|
import org.hibernate.cfg.AnnotatedClassType;
|
||||||
|
@ -217,19 +217,17 @@ public class MapBinder extends CollectionBinder {
|
||||||
//does not make sense for a map key element.setIgnoreNotFound( ignoreNotFound );
|
//does not make sense for a map key element.setIgnoreNotFound( ignoreNotFound );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
XClass keyXClass;
|
final XClass keyXClass;
|
||||||
AnnotatedClassType classType;
|
AnnotatedClassType classType;
|
||||||
if ( BinderHelper.PRIMITIVE_NAMES.contains( mapKeyType ) ) {
|
if ( BinderHelper.PRIMITIVE_NAMES.contains( mapKeyType ) ) {
|
||||||
classType = AnnotatedClassType.NONE;
|
classType = AnnotatedClassType.NONE;
|
||||||
keyXClass = null;
|
keyXClass = null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
final BootstrapContext bootstrapContext = buildingContext.getBootstrapContext();
|
||||||
keyXClass = buildingContext.getBootstrapContext().getReflectionManager().classForName( mapKeyType );
|
final Class<Object> mapKeyClass = bootstrapContext.getClassLoaderAccess().classForName( mapKeyType );
|
||||||
}
|
keyXClass = bootstrapContext.getReflectionManager().toXClass( mapKeyClass );
|
||||||
catch (ClassLoadingException e) {
|
|
||||||
throw new AnnotationException( "Unable to find class: " + mapKeyType, e );
|
|
||||||
}
|
|
||||||
classType = buildingContext.getMetadataCollector().getClassType( keyXClass );
|
classType = buildingContext.getMetadataCollector().getClassType( keyXClass );
|
||||||
// force in case of attribute override naming the key
|
// force in case of attribute override naming the key
|
||||||
if ( isEmbedded || mappingDefinedAttributeOverrideOnMapKey( property ) ) {
|
if ( isEmbedded || mappingDefinedAttributeOverrideOnMapKey( property ) ) {
|
||||||
|
|
|
@ -26,7 +26,6 @@ import org.hibernate.annotations.MapKeyType;
|
||||||
import org.hibernate.annotations.Nationalized;
|
import org.hibernate.annotations.Nationalized;
|
||||||
import org.hibernate.annotations.Parameter;
|
import org.hibernate.annotations.Parameter;
|
||||||
import org.hibernate.annotations.Type;
|
import org.hibernate.annotations.Type;
|
||||||
import org.hibernate.annotations.common.reflection.ClassLoadingException;
|
|
||||||
import org.hibernate.annotations.common.reflection.XClass;
|
import org.hibernate.annotations.common.reflection.XClass;
|
||||||
import org.hibernate.annotations.common.reflection.XProperty;
|
import org.hibernate.annotations.common.reflection.XProperty;
|
||||||
import org.hibernate.boot.model.TypeDefinition;
|
import org.hibernate.boot.model.TypeDefinition;
|
||||||
|
@ -534,27 +533,22 @@ public class SimpleValueBinder {
|
||||||
|
|
||||||
if ( simpleValue.getTypeName() != null && simpleValue.getTypeName().length() > 0
|
if ( simpleValue.getTypeName() != null && simpleValue.getTypeName().length() > 0
|
||||||
&& simpleValue.getMetadata().getTypeResolver().basic( simpleValue.getTypeName() ) == null ) {
|
&& simpleValue.getMetadata().getTypeResolver().basic( simpleValue.getTypeName() ) == null ) {
|
||||||
try {
|
Class typeClass = buildingContext.getBootstrapContext().getClassLoaderAccess().classForName( simpleValue.getTypeName() );
|
||||||
Class typeClass = buildingContext.getBootstrapContext().getClassLoaderAccess().classForName( simpleValue.getTypeName() );
|
|
||||||
|
|
||||||
if ( typeClass != null && DynamicParameterizedType.class.isAssignableFrom( typeClass ) ) {
|
if ( typeClass != null && DynamicParameterizedType.class.isAssignableFrom( typeClass ) ) {
|
||||||
Properties parameters = simpleValue.getTypeParameters();
|
Properties parameters = simpleValue.getTypeParameters();
|
||||||
if ( parameters == null ) {
|
if ( parameters == null ) {
|
||||||
parameters = new Properties();
|
parameters = new Properties();
|
||||||
}
|
|
||||||
parameters.put( DynamicParameterizedType.IS_DYNAMIC, Boolean.toString( true ) );
|
|
||||||
parameters.put( DynamicParameterizedType.RETURNED_CLASS, returnedClassName );
|
|
||||||
parameters.put( DynamicParameterizedType.IS_PRIMARY_KEY, Boolean.toString( key ) );
|
|
||||||
|
|
||||||
parameters.put( DynamicParameterizedType.ENTITY, persistentClassName );
|
|
||||||
parameters.put( DynamicParameterizedType.XPROPERTY, xproperty );
|
|
||||||
parameters.put( DynamicParameterizedType.PROPERTY, xproperty.getName() );
|
|
||||||
parameters.put( DynamicParameterizedType.ACCESS_TYPE, accessType.getType() );
|
|
||||||
simpleValue.setTypeParameters( parameters );
|
|
||||||
}
|
}
|
||||||
}
|
parameters.put( DynamicParameterizedType.IS_DYNAMIC, Boolean.toString( true ) );
|
||||||
catch (ClassLoadingException e) {
|
parameters.put( DynamicParameterizedType.RETURNED_CLASS, returnedClassName );
|
||||||
throw new MappingException( "Could not determine type for: " + simpleValue.getTypeName(), e );
|
parameters.put( DynamicParameterizedType.IS_PRIMARY_KEY, Boolean.toString( key ) );
|
||||||
|
|
||||||
|
parameters.put( DynamicParameterizedType.ENTITY, persistentClassName );
|
||||||
|
parameters.put( DynamicParameterizedType.XPROPERTY, xproperty );
|
||||||
|
parameters.put( DynamicParameterizedType.PROPERTY, xproperty.getName() );
|
||||||
|
parameters.put( DynamicParameterizedType.ACCESS_TYPE, accessType.getType() );
|
||||||
|
simpleValue.setTypeParameters( parameters );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class EventEngine {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.callbackBuilder.buildCallbacksForEntity( persistentClass.getClassName(), callbackRegistry );
|
this.callbackBuilder.buildCallbacksForEntity( persistentClass.getMappedClass(), callbackRegistry );
|
||||||
|
|
||||||
for ( Iterator<Property> propertyIterator = persistentClass.getDeclaredPropertyIterator(); propertyIterator.hasNext(); ) {
|
for ( Iterator<Property> propertyIterator = persistentClass.getDeclaredPropertyIterator(); propertyIterator.hasNext(); ) {
|
||||||
final Property property = propertyIterator.next();
|
final Property property = propertyIterator.next();
|
||||||
|
@ -69,7 +69,7 @@ public class EventEngine {
|
||||||
if ( property.getType().isComponentType() ) {
|
if ( property.getType().isComponentType() ) {
|
||||||
this.callbackBuilder.buildCallbacksForEmbeddable(
|
this.callbackBuilder.buildCallbacksForEmbeddable(
|
||||||
property,
|
property,
|
||||||
persistentClass.getClassName(),
|
persistentClass.getMappedClass(),
|
||||||
callbackRegistry
|
callbackRegistry
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ import javax.persistence.MappedSuperclass;
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
|
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.annotations.common.reflection.ClassLoadingException;
|
|
||||||
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
||||||
import org.hibernate.annotations.common.reflection.XClass;
|
import org.hibernate.annotations.common.reflection.XClass;
|
||||||
import org.hibernate.annotations.common.reflection.XMethod;
|
import org.hibernate.annotations.common.reflection.XMethod;
|
||||||
|
@ -52,53 +51,38 @@ final class CallbackBuilderLegacyImpl implements CallbackBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildCallbacksForEntity(String entityClassName, CallbackRegistrar callbackRegistrar) {
|
public void buildCallbacksForEntity(Class entityClass, CallbackRegistrar callbackRegistrar) {
|
||||||
try {
|
for ( CallbackType callbackType : CallbackType.values() ) {
|
||||||
final XClass entityXClass = reflectionManager.classForName( entityClassName );
|
if ( callbackRegistrar.hasRegisteredCallbacks( entityClass, callbackType ) ) {
|
||||||
final Class entityClass = reflectionManager.toClass( entityXClass );
|
// this most likely means we have a class mapped multiple times using the hbm.xml
|
||||||
for ( CallbackType callbackType : CallbackType.values() ) {
|
// "entity name" feature
|
||||||
if ( callbackRegistrar.hasRegisteredCallbacks( entityClass, callbackType ) ) {
|
if ( log.isDebugEnabled() ) {
|
||||||
// this most likely means we have a class mapped multiple times using the hbm.xml
|
log.debugf(
|
||||||
// "entity name" feature
|
"CallbackRegistry reported that Class [%s] already had %s callbacks registered; " +
|
||||||
if ( log.isDebugEnabled() ) {
|
"assuming this means the class was mapped twice " +
|
||||||
log.debugf(
|
"(using hbm.xml entity-name support) - skipping subsequent registrations",
|
||||||
"CallbackRegistry reported that Class [%s] already had %s callbacks registered; " +
|
entityClass.getName(),
|
||||||
"assuming this means the class was mapped twice " +
|
callbackType.getCallbackAnnotation().getSimpleName()
|
||||||
"(using hbm.xml entity-name support) - skipping subsequent registrations",
|
);
|
||||||
entityClassName,
|
|
||||||
callbackType.getCallbackAnnotation().getSimpleName()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
final Callback[] callbacks = resolveEntityCallbacks( entityXClass, callbackType, reflectionManager );
|
continue;
|
||||||
callbackRegistrar.registerCallbacks( entityClass, callbacks );
|
|
||||||
}
|
}
|
||||||
}
|
final Callback[] callbacks = resolveEntityCallbacks( entityClass, callbackType, reflectionManager );
|
||||||
catch (ClassLoadingException e) {
|
callbackRegistrar.registerCallbacks( entityClass, callbacks );
|
||||||
throw new MappingException( "entity class not found: " + entityClassName, e );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildCallbacksForEmbeddable(
|
public void buildCallbacksForEmbeddable(
|
||||||
Property embeddableProperty, String entityClassName, CallbackRegistrar callbackRegistrar) {
|
Property embeddableProperty, Class entityClass, CallbackRegistrar callbackRegistrar) {
|
||||||
try {
|
for ( CallbackType callbackType : CallbackType.values() ) {
|
||||||
final XClass entityXClass = reflectionManager.classForName( entityClassName );
|
final Callback[] callbacks = resolveEmbeddableCallbacks(
|
||||||
final Class entityClass = reflectionManager.toClass( entityXClass );
|
entityClass,
|
||||||
|
embeddableProperty,
|
||||||
for ( CallbackType callbackType : CallbackType.values() ) {
|
callbackType,
|
||||||
final Callback[] callbacks = resolveEmbeddableCallbacks(
|
reflectionManager
|
||||||
entityClass,
|
);
|
||||||
embeddableProperty,
|
callbackRegistrar.registerCallbacks( entityClass, callbacks );
|
||||||
callbackType,
|
|
||||||
reflectionManager
|
|
||||||
);
|
|
||||||
callbackRegistrar.registerCallbacks( entityClass, callbacks );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ClassLoadingException e) {
|
|
||||||
throw new MappingException( "Class not found: ", e );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,11 +92,11 @@ final class CallbackBuilderLegacyImpl implements CallbackBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "WeakerAccess"})
|
@SuppressWarnings({"unchecked", "WeakerAccess"})
|
||||||
public Callback[] resolveEntityCallbacks(XClass beanClass, CallbackType callbackType, ReflectionManager reflectionManager) {
|
public Callback[] resolveEntityCallbacks(Class entityClass, CallbackType callbackType, ReflectionManager reflectionManager) {
|
||||||
List<Callback> callbacks = new ArrayList<>();
|
List<Callback> callbacks = new ArrayList<>();
|
||||||
List<String> callbacksMethodNames = new ArrayList<>();
|
List<String> callbacksMethodNames = new ArrayList<>();
|
||||||
List<Class> orderedListeners = new ArrayList<>();
|
List<Class> orderedListeners = new ArrayList<>();
|
||||||
XClass currentClazz = beanClass;
|
XClass currentClazz = reflectionManager.toXClass( entityClass );
|
||||||
boolean stopListeners = false;
|
boolean stopListeners = false;
|
||||||
boolean stopDefaultListeners = false;
|
boolean stopDefaultListeners = false;
|
||||||
do {
|
do {
|
||||||
|
@ -140,7 +124,7 @@ final class CallbackBuilderLegacyImpl implements CallbackBuilder {
|
||||||
"Adding %s as %s callback for entity %s",
|
"Adding %s as %s callback for entity %s",
|
||||||
methodName,
|
methodName,
|
||||||
callbackType.getCallbackAnnotation().getSimpleName(),
|
callbackType.getCallbackAnnotation().getSimpleName(),
|
||||||
beanClass.getName()
|
entityClass.getName()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
callbacks.add( 0, callback ); //superclass first
|
callbacks.add( 0, callback ); //superclass first
|
||||||
|
@ -149,7 +133,7 @@ final class CallbackBuilderLegacyImpl implements CallbackBuilder {
|
||||||
else {
|
else {
|
||||||
throw new PersistenceException(
|
throw new PersistenceException(
|
||||||
"You can only annotate one callback method with "
|
"You can only annotate one callback method with "
|
||||||
+ callbackType.getCallbackAnnotation().getName() + " in bean class: " + beanClass.getName()
|
+ callbackType.getCallbackAnnotation().getName() + " in bean class: " + entityClass.getName()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,7 +200,7 @@ final class CallbackBuilderLegacyImpl implements CallbackBuilder {
|
||||||
"Adding %s as %s callback for entity %s",
|
"Adding %s as %s callback for entity %s",
|
||||||
methodName,
|
methodName,
|
||||||
callbackType.getCallbackAnnotation().getSimpleName(),
|
callbackType.getCallbackAnnotation().getSimpleName(),
|
||||||
beanClass.getName()
|
entityClass.getName()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
callbacks.add( 0, callback ); // listeners first
|
callbacks.add( 0, callback ); // listeners first
|
||||||
|
@ -225,7 +209,7 @@ final class CallbackBuilderLegacyImpl implements CallbackBuilder {
|
||||||
throw new PersistenceException(
|
throw new PersistenceException(
|
||||||
"You can only annotate one callback method with "
|
"You can only annotate one callback method with "
|
||||||
+ callbackType.getCallbackAnnotation().getName()
|
+ callbackType.getCallbackAnnotation().getName()
|
||||||
+ " in bean class: " + beanClass.getName()
|
+ " in bean class: " + entityClass.getName()
|
||||||
+ " and callback listener: " + listener.getName()
|
+ " and callback listener: " + listener.getName()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -240,8 +224,8 @@ final class CallbackBuilderLegacyImpl implements CallbackBuilder {
|
||||||
@SuppressWarnings({"unchecked", "WeakerAccess"})
|
@SuppressWarnings({"unchecked", "WeakerAccess"})
|
||||||
public Callback[] resolveEmbeddableCallbacks(Class entityClass, Property embeddableProperty, CallbackType callbackType, ReflectionManager reflectionManager) {
|
public Callback[] resolveEmbeddableCallbacks(Class entityClass, Property embeddableProperty, CallbackType callbackType, ReflectionManager reflectionManager) {
|
||||||
|
|
||||||
final String embeddableClassName = embeddableProperty.getType().getReturnedClass().getName();
|
final Class embeddableClass = embeddableProperty.getType().getReturnedClass();
|
||||||
final XClass embeddableXClass = reflectionManager.classForName( embeddableClassName );
|
final XClass embeddableXClass = reflectionManager.toXClass( embeddableClass );
|
||||||
final Getter embeddableGetter = embeddableProperty.getGetter( entityClass );
|
final Getter embeddableGetter = embeddableProperty.getGetter( entityClass );
|
||||||
final List<Callback> callbacks = new ArrayList<>();
|
final List<Callback> callbacks = new ArrayList<>();
|
||||||
final List<String> callbacksMethodNames = new ArrayList<>();
|
final List<String> callbacksMethodNames = new ArrayList<>();
|
||||||
|
|
|
@ -12,12 +12,12 @@ import org.hibernate.mapping.Property;
|
||||||
final class EmptyCallbackBuilder implements CallbackBuilder {
|
final class EmptyCallbackBuilder implements CallbackBuilder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildCallbacksForEntity(String entityClassName, CallbackRegistrar callbackRegistrar) {
|
public void buildCallbacksForEntity(Class entityClass, CallbackRegistrar callbackRegistrar) {
|
||||||
//no-op
|
//no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildCallbacksForEmbeddable(Property embeddableProperty, String entityClassName, CallbackRegistrar callbackRegistrar) {
|
public void buildCallbacksForEmbeddable(Property embeddableProperty, Class entityClass, CallbackRegistrar callbackRegistrar) {
|
||||||
//no-op
|
//no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,11 +28,11 @@ public interface CallbackBuilder {
|
||||||
void registerCallbacks(Class entityClass, Callback[] callbacks);
|
void registerCallbacks(Class entityClass, Callback[] callbacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
void buildCallbacksForEntity(String entityClassName, CallbackRegistrar callbackRegistrar);
|
void buildCallbacksForEntity(Class entityClass, CallbackRegistrar callbackRegistrar);
|
||||||
|
|
||||||
void buildCallbacksForEmbeddable(
|
void buildCallbacksForEmbeddable(
|
||||||
Property embeddableProperty,
|
Property embeddableProperty,
|
||||||
String entityClassName,
|
Class entityClass,
|
||||||
CallbackRegistrar callbackRegistrar);
|
CallbackRegistrar callbackRegistrar);
|
||||||
|
|
||||||
void release();
|
void release();
|
||||||
|
|
|
@ -11,7 +11,6 @@ import java.util.Set;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
|
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.annotations.common.reflection.ClassLoadingException;
|
|
||||||
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
||||||
import org.hibernate.annotations.common.reflection.XClass;
|
import org.hibernate.annotations.common.reflection.XClass;
|
||||||
import org.hibernate.annotations.common.reflection.XProperty;
|
import org.hibernate.annotations.common.reflection.XProperty;
|
||||||
|
@ -310,14 +309,7 @@ public class RevisionInfoConfiguration {
|
||||||
for ( PersistentClass persistentClass : metadata.getEntityBindings() ) {
|
for ( PersistentClass persistentClass : metadata.getEntityBindings() ) {
|
||||||
// Ensure we're in POJO, not dynamic model, mapping.
|
// Ensure we're in POJO, not dynamic model, mapping.
|
||||||
if (persistentClass.getClassName() != null) {
|
if (persistentClass.getClassName() != null) {
|
||||||
XClass clazz;
|
XClass clazz = reflectionManager.toXClass( persistentClass.getMappedClass() );
|
||||||
try {
|
|
||||||
clazz = reflectionManager.classForName( persistentClass.getClassName() );
|
|
||||||
}
|
|
||||||
catch (ClassLoadingException e) {
|
|
||||||
throw new MappingException( e );
|
|
||||||
}
|
|
||||||
|
|
||||||
final RevisionEntity revisionEntity = clazz.getAnnotation( RevisionEntity.class );
|
final RevisionEntity revisionEntity = clazz.getAnnotation( RevisionEntity.class );
|
||||||
if ( revisionEntity != null ) {
|
if ( revisionEntity != null ) {
|
||||||
if (revisionEntityFound) {
|
if (revisionEntityFound) {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import javax.persistence.JoinColumn;
|
||||||
import org.dom4j.Element;
|
import org.dom4j.Element;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
||||||
|
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||||
import org.hibernate.envers.ModificationStore;
|
import org.hibernate.envers.ModificationStore;
|
||||||
import org.hibernate.envers.RelationTargetAuditMode;
|
import org.hibernate.envers.RelationTargetAuditMode;
|
||||||
import org.hibernate.envers.configuration.internal.metadata.reader.AuditedPropertiesReader;
|
import org.hibernate.envers.configuration.internal.metadata.reader.AuditedPropertiesReader;
|
||||||
|
@ -658,9 +659,12 @@ public final class CollectionMetadataGenerator {
|
||||||
.getMetadataBuildingOptions()
|
.getMetadataBuildingOptions()
|
||||||
.getReflectionManager();
|
.getReflectionManager();
|
||||||
|
|
||||||
|
final ClassLoaderService classLoaderService = mainGenerator.getGlobalCfg()
|
||||||
|
.getEnversService()
|
||||||
|
.getClassLoaderService();
|
||||||
new ComponentAuditedPropertiesReader(
|
new ComponentAuditedPropertiesReader(
|
||||||
ModificationStore.FULL,
|
ModificationStore.FULL,
|
||||||
new AuditedPropertiesReader.ComponentPropertiesSource( reflectionManager, component ),
|
new AuditedPropertiesReader.ComponentPropertiesSource( classLoaderService, reflectionManager, component ),
|
||||||
auditData, mainGenerator.getGlobalCfg(), reflectionManager, ""
|
auditData, mainGenerator.getGlobalCfg(), reflectionManager, ""
|
||||||
).read();
|
).read();
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
package org.hibernate.envers.configuration.internal.metadata.reader;
|
package org.hibernate.envers.configuration.internal.metadata.reader;
|
||||||
|
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.annotations.common.reflection.ClassLoadingException;
|
|
||||||
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
||||||
import org.hibernate.annotations.common.reflection.XClass;
|
import org.hibernate.annotations.common.reflection.XClass;
|
||||||
import org.hibernate.envers.AuditTable;
|
import org.hibernate.envers.AuditTable;
|
||||||
|
@ -96,30 +95,25 @@ public final class AnnotationsMetadataReader {
|
||||||
return auditData;
|
return auditData;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
final XClass xclass = reflectionManager.toXClass( pc.getMappedClass() );
|
||||||
final XClass xclass = reflectionManager.classForName( pc.getClassName() );
|
|
||||||
|
|
||||||
final ModificationStore defaultStore = getDefaultAudited( xclass );
|
final ModificationStore defaultStore = getDefaultAudited( xclass );
|
||||||
if ( defaultStore != null ) {
|
if ( defaultStore != null ) {
|
||||||
auditData.setDefaultAudited( true );
|
auditData.setDefaultAudited( true );
|
||||||
}
|
|
||||||
|
|
||||||
new AuditedPropertiesReader(
|
|
||||||
defaultStore,
|
|
||||||
new PersistentClassPropertiesSource( xclass ),
|
|
||||||
auditData,
|
|
||||||
globalCfg,
|
|
||||||
reflectionManager,
|
|
||||||
""
|
|
||||||
).read();
|
|
||||||
|
|
||||||
addAuditTable( xclass );
|
|
||||||
addAuditSecondaryTables( xclass );
|
|
||||||
}
|
|
||||||
catch (ClassLoadingException e) {
|
|
||||||
throw new MappingException( e );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new AuditedPropertiesReader(
|
||||||
|
defaultStore,
|
||||||
|
new PersistentClassPropertiesSource( xclass ),
|
||||||
|
auditData,
|
||||||
|
globalCfg,
|
||||||
|
reflectionManager,
|
||||||
|
""
|
||||||
|
).read();
|
||||||
|
|
||||||
|
addAuditTable( xclass );
|
||||||
|
addAuditSecondaryTables( xclass );
|
||||||
|
|
||||||
return auditData;
|
return auditData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,11 @@ import javax.persistence.Version;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.annotations.common.reflection.ClassLoadingException;
|
|
||||||
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
||||||
import org.hibernate.annotations.common.reflection.XClass;
|
import org.hibernate.annotations.common.reflection.XClass;
|
||||||
import org.hibernate.annotations.common.reflection.XProperty;
|
import org.hibernate.annotations.common.reflection.XProperty;
|
||||||
|
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||||
|
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
||||||
import org.hibernate.envers.AuditJoinTable;
|
import org.hibernate.envers.AuditJoinTable;
|
||||||
import org.hibernate.envers.AuditMappedBy;
|
import org.hibernate.envers.AuditMappedBy;
|
||||||
import org.hibernate.envers.AuditOverride;
|
import org.hibernate.envers.AuditOverride;
|
||||||
|
@ -432,8 +433,10 @@ public class AuditedPropertiesReader {
|
||||||
// Marking component properties as placed directly in class (not inside another component).
|
// Marking component properties as placed directly in class (not inside another component).
|
||||||
componentData.setBeanName( null );
|
componentData.setBeanName( null );
|
||||||
|
|
||||||
|
final ClassLoaderService classLoaderService = globalCfg.getEnversService().getClassLoaderService();
|
||||||
|
|
||||||
final PersistentPropertiesSource componentPropertiesSource = new ComponentPropertiesSource(
|
final PersistentPropertiesSource componentPropertiesSource = new ComponentPropertiesSource(
|
||||||
reflectionManager,
|
classLoaderService, reflectionManager,
|
||||||
propertyValue
|
propertyValue
|
||||||
);
|
);
|
||||||
final AuditedPropertiesReader audPropReader = new AuditedPropertiesReader(
|
final AuditedPropertiesReader audPropReader = new AuditedPropertiesReader(
|
||||||
|
@ -459,7 +462,10 @@ public class AuditedPropertiesReader {
|
||||||
componentPropertiesSource = new DynamicComponentSource( reflectionManager, propertyValue, property );
|
componentPropertiesSource = new DynamicComponentSource( reflectionManager, propertyValue, property );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
componentPropertiesSource = new ComponentPropertiesSource( reflectionManager, propertyValue );
|
final ClassLoaderService classLoaderService = this.globalCfg.getEnversService().getClassLoaderService();
|
||||||
|
componentPropertiesSource = new ComponentPropertiesSource(
|
||||||
|
classLoaderService,
|
||||||
|
reflectionManager, propertyValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
final ComponentAuditedPropertiesReader audPropReader = new ComponentAuditedPropertiesReader(
|
final ComponentAuditedPropertiesReader audPropReader = new ComponentAuditedPropertiesReader(
|
||||||
|
@ -786,14 +792,17 @@ public class AuditedPropertiesReader {
|
||||||
this.component = component;
|
this.component = component;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ComponentPropertiesSource(ReflectionManager reflectionManager, Component component) {
|
public ComponentPropertiesSource(
|
||||||
|
ClassLoaderService classLoaderService,
|
||||||
|
ReflectionManager reflectionManager,
|
||||||
|
Component component) {
|
||||||
try {
|
try {
|
||||||
this.xclass = reflectionManager.classForName( component.getComponentClassName() );
|
Class<Object> objectClass = classLoaderService.classForName( component.getComponentClassName() );
|
||||||
|
this.xclass = reflectionManager.toXClass( objectClass );
|
||||||
}
|
}
|
||||||
catch ( ClassLoadingException e ) {
|
catch ( ClassLoadingException e ) {
|
||||||
throw new MappingException( e );
|
throw new MappingException( e );
|
||||||
}
|
}
|
||||||
|
|
||||||
this.component = component;
|
this.component = component;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue