HHH-6335 : Change PojoEntitySpecifics to use JavaType for entity and proxy classes

This commit is contained in:
Gail Badner 2011-06-20 15:21:05 -07:00
parent 86e98b2432
commit 2129f94aa3
2 changed files with 24 additions and 11 deletions

View File

@ -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();
}
}

View File

@ -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 );