From e93a83f5c2c78ef086de7f3b02bbbc14ec9baa10 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Fri, 14 Oct 2011 01:39:21 +0100 Subject: [PATCH] HHH-6733 Avoid frequent usage of ReflectHelper in PojoInstantiator --- .../java/org/hibernate/tuple/PojoInstantiator.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/tuple/PojoInstantiator.java b/hibernate-core/src/main/java/org/hibernate/tuple/PojoInstantiator.java index fecfa2a960..ffcc002293 100755 --- a/hibernate-core/src/main/java/org/hibernate/tuple/PojoInstantiator.java +++ b/hibernate-core/src/main/java/org/hibernate/tuple/PojoInstantiator.java @@ -51,9 +51,11 @@ public class PojoInstantiator implements Instantiator, Serializable { private final transient ReflectionOptimizer.InstantiationOptimizer optimizer; private final boolean embeddedIdentifier; private final Class proxyInterface; + private final boolean isAbstract; public PojoInstantiator(Component component, ReflectionOptimizer.InstantiationOptimizer optimizer) { this.mappedClass = component.getComponentClass(); + this.isAbstract = ReflectHelper.isAbstractClass( mappedClass ); this.optimizer = optimizer; this.proxyInterface = null; @@ -63,13 +65,14 @@ public class PojoInstantiator implements Instantiator, Serializable { constructor = ReflectHelper.getDefaultConstructor(mappedClass); } catch ( PropertyNotFoundException pnfe ) { - LOG.noDefaultConstructor(mappedClass.getName()); + LOG.noDefaultConstructor(mappedClass.getName()); constructor = null; } } public PojoInstantiator(PersistentClass persistentClass, ReflectionOptimizer.InstantiationOptimizer optimizer) { this.mappedClass = persistentClass.getMappedClass(); + this.isAbstract = ReflectHelper.isAbstractClass( mappedClass ); this.proxyInterface = persistentClass.getProxyInterface(); this.embeddedIdentifier = persistentClass.hasEmbeddedIdentifier(); this.optimizer = optimizer; @@ -78,13 +81,14 @@ public class PojoInstantiator implements Instantiator, Serializable { constructor = ReflectHelper.getDefaultConstructor( mappedClass ); } catch ( PropertyNotFoundException pnfe ) { - LOG.noDefaultConstructor(mappedClass.getName()); + LOG.noDefaultConstructor(mappedClass.getName()); constructor = null; } } public PojoInstantiator(EntityBinding entityBinding, ReflectionOptimizer.InstantiationOptimizer optimizer) { this.mappedClass = entityBinding.getEntity().getClassReference(); + this.isAbstract = ReflectHelper.isAbstractClass( mappedClass ); this.proxyInterface = entityBinding.getProxyInterfaceType().getValue(); this.embeddedIdentifier = entityBinding.getHierarchyDetails().getEntityIdentifier().isEmbedded(); this.optimizer = optimizer; @@ -105,7 +109,7 @@ public class PojoInstantiator implements Instantiator, Serializable { } public Object instantiate() { - if ( ReflectHelper.isAbstractClass(mappedClass) ) { + if ( isAbstract ) { throw new InstantiationException( "Cannot instantiate abstract class or interface: ", mappedClass ); } else if ( optimizer != null ) {