diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/domain/Entity.java b/hibernate-core/src/main/java/org/hibernate/metamodel/domain/Entity.java index f51daf02f2..2e2ba49fb8 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/domain/Entity.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/domain/Entity.java @@ -24,6 +24,7 @@ package org.hibernate.metamodel.domain; import org.hibernate.EntityMode; +import org.hibernate.service.classloading.spi.ClassLoaderService; /** * Models the notion of an entity @@ -68,8 +69,8 @@ public class Entity extends AbstractAttributeContainer { public static class PojoEntitySpecifics implements EntityModeEntitySpecifics { private String tuplizerClassName; - private String className; - private String proxyInterfaceName; + private JavaType entityClass; + private JavaType proxyInterface; @Override public EntityMode getEntityMode() { @@ -85,19 +86,27 @@ public class Entity extends AbstractAttributeContainer { } public String getClassName() { - return className; + return entityClass.getName(); } - public void setClassName(String className) { - this.className = className; + public void setClassName(String className, ClassLoaderService classLoaderService) { + this.entityClass = new JavaType( className, classLoaderService ); + } + + public Class getEntityClass() { + return entityClass.getClassReference(); } public String getProxyInterfaceName() { - return proxyInterfaceName; + return proxyInterface.getName(); } - public void setProxyInterfaceName(String proxyInterfaceName) { - this.proxyInterfaceName = proxyInterfaceName; + public void setProxyInterfaceName(String proxyInterfaceName, ClassLoaderService classLoaderService) { + this.proxyInterface = new JavaType( proxyInterfaceName, classLoaderService ); + } + + public Class getProxyInterfaceClass() { + return proxyInterface.getClassReference(); } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/AbstractEntityBinder.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/AbstractEntityBinder.java index cc5f735356..5ca87a7e5a 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/AbstractEntityBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/AbstractEntityBinder.java @@ -75,6 +75,7 @@ import org.hibernate.metamodel.binding.state.SimpleAttributeBindingState; import org.hibernate.metamodel.relational.state.TupleRelationalState; import org.hibernate.metamodel.relational.state.ValueRelationalState; import org.hibernate.metamodel.source.spi.MetadataImplementor; +import org.hibernate.service.classloading.spi.ClassLoaderService; /** * TODO : javadoc @@ -154,14 +155,17 @@ abstract class AbstractEntityBinder { String className = bindingContext.getClassName( entityClazz.getName() ); String proxyName = entityBinding.getProxyInterfaceName(); - entityBinding.getEntity().getPojoEntitySpecifics().setClassName( className ); + final ClassLoaderService classLoaderService = + bindingContext.getServiceRegistry().getService( ClassLoaderService.class ); + + entityBinding.getEntity().getPojoEntitySpecifics().setClassName( className, classLoaderService ); if ( proxyName != null ) { - entityBinding.getEntity().getPojoEntitySpecifics().setProxyInterfaceName( proxyName ); + entityBinding.getEntity().getPojoEntitySpecifics().setProxyInterfaceName( proxyName, classLoaderService ); entityBinding.setLazy( true ); } else if ( entityBinding.isLazy() ) { - entityBinding.getEntity().getPojoEntitySpecifics().setProxyInterfaceName( className ); + entityBinding.getEntity().getPojoEntitySpecifics().setProxyInterfaceName( className, classLoaderService ); } XMLTuplizerElement tuplizer = locateTuplizerDefinition( entityClazz, EntityMode.POJO );