mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-20 01:55:02 +00:00
HHH-7832 - map entity mode support, not finished yet
This commit is contained in:
parent
7c48f03874
commit
01bab54f46
@ -42,6 +42,7 @@
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
@ -58,6 +59,7 @@
|
||||
import org.hibernate.event.spi.EventType;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.Property;
|
||||
@ -254,6 +256,9 @@ public static void applyDDL(Iterable<EntityBinding> bindings,
|
||||
|
||||
for ( EntityBinding binding : bindings ) {
|
||||
final String className = binding.getEntity().getClassName();
|
||||
if ( binding.getHierarchyDetails().getEntityMode() != EntityMode.POJO ){
|
||||
continue;
|
||||
}
|
||||
Class<?> clazz;
|
||||
try {
|
||||
clazz = classLoaderService.classForName( className );
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.jpa.metamodel.internal.AbstractIdentifiableType;
|
||||
@ -93,7 +94,9 @@ public MetamodelBuilder(SessionFactoryImplementor sessionFactory, JpaMetaModelPo
|
||||
}
|
||||
|
||||
public void add(EntityBinding entityBinding) {
|
||||
locateOrBuildEntityType( entityBinding );
|
||||
if ( entityBinding.getHierarchyDetails().getEntityMode() == EntityMode.POJO ) {
|
||||
locateOrBuildEntityType( entityBinding );
|
||||
}
|
||||
entityBindingList.add( entityBinding );
|
||||
}
|
||||
|
||||
|
@ -1848,8 +1848,7 @@ private void bindPrimaryTable(final EntityBinding entityBinding, final EntitySou
|
||||
@Override
|
||||
public String defaultName() {
|
||||
String name = StringHelper.isNotEmpty( entityBinding.getJpaEntityName() ) ? entityBinding.getJpaEntityName() : entityBinding
|
||||
.getEntity()
|
||||
.getClassName();
|
||||
.getEntity().getName();
|
||||
return bindingContexts.peek().getNamingStrategy().classToTableName( name );
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.internal.util.beans.BeanInfoHelper;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
@ -109,8 +110,12 @@ public void bindSingularAttributeTypeInformation(
|
||||
final HibernateTypeDescriptor hibernateTypeDescriptor = attributeBinding
|
||||
.getHibernateTypeDescriptor();
|
||||
|
||||
final Class<?> attributeJavaType = determineJavaType(
|
||||
attributeBinding.getAttribute() );
|
||||
final Class<?> attributeJavaType = attributeBinding.getContainer()
|
||||
.seekEntityBinding()
|
||||
.getHierarchyDetails()
|
||||
.getEntityMode() == EntityMode.POJO ? determineJavaType(
|
||||
attributeBinding.getAttribute()
|
||||
) : null;
|
||||
if ( attributeJavaType != null ) {
|
||||
attributeBinding.getAttribute().resolveType( makeJavaType(
|
||||
attributeJavaType.getName() ) );
|
||||
@ -308,6 +313,9 @@ private void pushHibernateTypeInformationDown(
|
||||
Type resolvedHibernateType) {
|
||||
final HibernateTypeDescriptor hibernateTypeDescriptor = attributeBinding.getHibernateTypeDescriptor();
|
||||
final SingularAttribute singularAttribute = SingularAttribute.class.cast( attributeBinding.getAttribute() );
|
||||
if ( hibernateTypeDescriptor.getResolvedTypeMapping() != null && hibernateTypeDescriptor.getJavaTypeName() == null ) {
|
||||
hibernateTypeDescriptor.setJavaTypeName( resolvedHibernateType.getReturnedClass().getName() );
|
||||
}
|
||||
if ( ! singularAttribute.isTypeResolved() && hibernateTypeDescriptor.getJavaTypeName() != null ) {
|
||||
singularAttribute.resolveType( makeJavaType( hibernateTypeDescriptor.getJavaTypeName() ) );
|
||||
}
|
||||
|
@ -439,6 +439,12 @@ public static Setter getIdentifierMapperSetter(
|
||||
}
|
||||
|
||||
private static Getter getGetterOrNull(AttributeBinding mappingProperty) {
|
||||
if ( mappingProperty.getContainer()
|
||||
.seekEntityBinding()
|
||||
.getHierarchyDetails()
|
||||
.getEntityMode() != EntityMode.POJO ) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return getGetter( mappingProperty );
|
||||
}
|
||||
|
@ -70,7 +70,14 @@ public class DynamicMapEntityTuplizer extends AbstractEntityTuplizer {
|
||||
public EntityMode getEntityMode() {
|
||||
return EntityMode.MAP;
|
||||
}
|
||||
|
||||
private PropertyAccessor buildPropertyAccessor(AttributeBinding mappedProperty) {
|
||||
if ( mappedProperty.isBackRef() ) {
|
||||
return PropertyAccessorFactory.getPropertyAccessor( "map" ); //todo use getPropertyAccessorName instead of hardcode
|
||||
}
|
||||
else {
|
||||
return PropertyAccessorFactory.getDynamicMapPropertyAccessor();
|
||||
}
|
||||
}
|
||||
private PropertyAccessor buildPropertyAccessor(Property mappedProperty) {
|
||||
if ( mappedProperty.isBackRef() ) {
|
||||
return mappedProperty.getPropertyAccessor(null);
|
||||
@ -134,7 +141,7 @@ protected ProxyFactory buildProxyFactory(PersistentClass mappingInfo, Getter idG
|
||||
*/
|
||||
@Override
|
||||
protected Getter buildPropertyGetter(AttributeBinding mappedProperty) {
|
||||
return PropertyFactory.getGetter( mappedProperty );
|
||||
return buildPropertyAccessor(mappedProperty).getGetter( null, mappedProperty.getAttribute().getName() );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -142,7 +149,7 @@ protected Getter buildPropertyGetter(AttributeBinding mappedProperty) {
|
||||
*/
|
||||
@Override
|
||||
protected Setter buildPropertySetter(AttributeBinding mappedProperty) {
|
||||
return PropertyFactory.getSetter( mappedProperty );
|
||||
return buildPropertyAccessor(mappedProperty).getSetter( null, mappedProperty.getAttribute().getName() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -382,15 +382,18 @@ public EntityMetamodel(EntityBinding entityBinding, SessionFactoryImplementor se
|
||||
|
||||
versioned = entityBinding.isVersioned();
|
||||
|
||||
boolean hasPojoRepresentation = false;
|
||||
Class<?> mappedClass = null;
|
||||
boolean hasPojoRepresentation = entityBinding.getHierarchyDetails().getEntityMode() == EntityMode.POJO;
|
||||
Class<?> proxyInterfaceClass = null;
|
||||
if ( entityBinding.getEntity().getClassReferenceUnresolved() != null ) {
|
||||
hasPojoRepresentation = true;
|
||||
Class<?> mappedClass = null;
|
||||
if ( hasPojoRepresentation ) {
|
||||
mappedClass = entityBinding.getEntity().getClassReference();
|
||||
proxyInterfaceClass = entityBinding.getProxyInterfaceType().getValue();
|
||||
instrumentationMetadata = Environment.getBytecodeProvider().getEntityInstrumentationMetadata( mappedClass );
|
||||
}
|
||||
instrumentationMetadata = Environment.getBytecodeProvider().getEntityInstrumentationMetadata( mappedClass );
|
||||
else {
|
||||
instrumentationMetadata = new NonPojoInstrumentationMetadata( entityBinding.getEntity().getName() );
|
||||
}
|
||||
|
||||
|
||||
boolean hasLazy = false;
|
||||
|
||||
|
@ -28,13 +28,11 @@
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public class SubclassDynamicMapTest extends BaseCoreFunctionalTestCase {
|
||||
@Override
|
||||
public String[] getMappings() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user