diff --git a/hibernate-core/src/main/java/org/hibernate/EntityMode.java b/hibernate-core/src/main/java/org/hibernate/EntityMode.java
index 1f07ca88d4..666ef60a34 100644
--- a/hibernate-core/src/main/java/org/hibernate/EntityMode.java
+++ b/hibernate-core/src/main/java/org/hibernate/EntityMode.java
@@ -8,11 +8,16 @@ package org.hibernate;
import java.util.Locale;
+import org.hibernate.metamodel.RepresentationMode;
+
/**
* Defines the representation modes available for entities.
*
* @author Steve Ebersole
+ *
+ * @deprecated See {@link RepresentationMode}
*/
+@Deprecated
public enum EntityMode {
/**
* The {@code pojo} entity mode describes an entity model made up of entity classes (loosely) following
diff --git a/hibernate-core/src/main/java/org/hibernate/Interceptor.java b/hibernate-core/src/main/java/org/hibernate/Interceptor.java
index f71df01f64..0ed8cba5d0 100644
--- a/hibernate-core/src/main/java/org/hibernate/Interceptor.java
+++ b/hibernate-core/src/main/java/org/hibernate/Interceptor.java
@@ -9,6 +9,8 @@ package org.hibernate;
import java.io.Serializable;
import java.util.Iterator;
+import org.hibernate.metamodel.RepresentationMode;
+import org.hibernate.metamodel.spi.EntityRepresentationStrategy;
import org.hibernate.type.Type;
/**
@@ -202,6 +204,7 @@ public interface Interceptor {
Object[] previousState,
String[] propertyNames,
Type[] types);
+
/**
* Instantiate the entity class. Return null to indicate that Hibernate should use
* the default constructor of the class. The identifier property of the returned instance
@@ -214,9 +217,24 @@ public interface Interceptor {
* @return an instance of the class, or null to choose default behaviour
*
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
+ *
+ * @deprecated Use {@link #instantiate(String, EntityRepresentationStrategy, Object)} instead
*/
+ @Deprecated
Object instantiate(String entityName, EntityMode entityMode, Serializable id) throws CallbackException;
+ /**
+ * Instantiate the entity. Return null to indicate that Hibernate should use
+ * the default constructor of the class. The identifier property of the returned instance
+ * should be initialized with the given identifier.
+ */
+ default Object instantiate(
+ String entityName,
+ EntityRepresentationStrategy representationStrategy,
+ Object id) throws CallbackException {
+ return instantiate( entityName, representationStrategy.getMode().getLegacyEntityMode(), (Serializable) id );
+ }
+
/**
* Get the entity name for a persistent or transient instance.
*
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/internal/BootstrapContextImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/internal/BootstrapContextImpl.java
index c9c247d019..f8ad0d4180 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/internal/BootstrapContextImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/internal/BootstrapContextImpl.java
@@ -38,6 +38,8 @@ import org.hibernate.dialect.function.SQLFunction;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.jpa.internal.MutableJpaComplianceImpl;
import org.hibernate.jpa.spi.MutableJpaCompliance;
+import org.hibernate.metamodel.internal.StandardManagedTypeRepresentationResolver;
+import org.hibernate.metamodel.spi.ManagedTypeRepresentationResolver;
import org.hibernate.type.spi.TypeConfiguration;
import org.jboss.jandex.IndexView;
@@ -76,6 +78,7 @@ public class BootstrapContextImpl implements BootstrapContext {
private ArrayList auxiliaryDatabaseObjectList;
private HashMap attributeConverterDescriptorMap;
private ArrayList cacheRegionDefinitions;
+ private ManagedTypeRepresentationResolver representationStrategySelector;
public BootstrapContextImpl(
StandardServiceRegistry serviceRegistry,
@@ -109,6 +112,9 @@ public class BootstrapContextImpl implements BootstrapContext {
ArchiveDescriptorFactory.class,
configService.getSettings().get( AvailableSettings.SCANNER_ARCHIVE_INTERPRETER )
);
+
+ this.representationStrategySelector = StandardManagedTypeRepresentationResolver.INSTANCE;
+
this.typeConfiguration = new TypeConfiguration();
}
@@ -237,6 +243,12 @@ public class BootstrapContextImpl implements BootstrapContext {
}
}
+ @Override
+ public ManagedTypeRepresentationResolver getRepresentationStrategySelector() {
+ return representationStrategySelector;
+ }
+
+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Mutations
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/spi/BootstrapContext.java b/hibernate-core/src/main/java/org/hibernate/boot/spi/BootstrapContext.java
index 0996c81a60..ae5c6660fa 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/spi/BootstrapContext.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/spi/BootstrapContext.java
@@ -21,6 +21,7 @@ import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.dialect.function.SQLFunction;
import org.hibernate.jpa.spi.MutableJpaCompliance;
+import org.hibernate.metamodel.spi.ManagedTypeRepresentationResolver;
import org.hibernate.type.spi.TypeConfiguration;
import org.jboss.jandex.IndexView;
@@ -171,4 +172,6 @@ public interface BootstrapContext {
* @todo verify this ^^
*/
void release();
+
+ ManagedTypeRepresentationResolver getRepresentationStrategySelector();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/none/DisallowedProxyFactory.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/none/DisallowedProxyFactory.java
index 1ae529ffd9..9212384a75 100644
--- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/none/DisallowedProxyFactory.java
+++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/none/DisallowedProxyFactory.java
@@ -11,7 +11,6 @@ import java.lang.reflect.Method;
import java.util.Set;
import org.hibernate.HibernateException;
-import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.proxy.ProxyFactory;
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/FetchStrategy.java b/hibernate-core/src/main/java/org/hibernate/engine/FetchStrategy.java
index b29acf18f9..22f137d5e3 100644
--- a/hibernate-core/src/main/java/org/hibernate/engine/FetchStrategy.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/FetchStrategy.java
@@ -12,6 +12,8 @@ package org.hibernate.engine;
* @author Steve Ebersole
*/
public class FetchStrategy {
+ public static FetchStrategy IMMEDIATE_JOIN = new FetchStrategy( FetchTiming.IMMEDIATE, FetchStyle.JOIN );
+
private final FetchTiming timing;
private final FetchStyle style;
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/EntityKey.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/EntityKey.java
index 52a9cd8706..fd1c383ffe 100644
--- a/hibernate-core/src/main/java/org/hibernate/engine/spi/EntityKey.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/EntityKey.java
@@ -31,7 +31,7 @@ import org.hibernate.pretty.MessageHelper;
*/
public final class EntityKey implements Serializable {
- private final Serializable identifier;
+ private final Object identifier;
private final int hashCode;
private final EntityPersister persister;
@@ -45,7 +45,7 @@ public final class EntityKey implements Serializable {
* @param id The entity id
* @param persister The entity persister
*/
- public EntityKey(Serializable id, EntityPersister persister) {
+ public EntityKey(Object id, EntityPersister persister) {
this.persister = persister;
if ( id == null ) {
throw new AssertionFailure( "null identifier" );
@@ -66,10 +66,14 @@ public final class EntityKey implements Serializable {
return persister.isBatchLoadable();
}
- public Serializable getIdentifier() {
+ public Object getIdentifierValue() {
return identifier;
}
+ public Serializable getIdentifier() {
+ return (Serializable) identifier;
+ }
+
public String getEntityName() {
return persister.getEntityName();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultLoadEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultLoadEventListener.java
index 432b8650db..9e24e89934 100644
--- a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultLoadEventListener.java
+++ b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultLoadEventListener.java
@@ -256,9 +256,7 @@ public class DefaultLoadEventListener implements LoadEventListener {
.isEnhancementAsProxyEnabled();
final EntityMetamodel entityMetamodel = persister.getEntityMetamodel();
- final boolean entityHasHibernateProxyFactory = entityMetamodel
- .getTuplizer()
- .getProxyFactory() != null;
+ final boolean entityHasHibernateProxyFactory = persister.getRepresentationStrategy().getProxyFactory() != null;
// Check for the case where we can use the entity itself as a proxy
if ( options.isAllowProxyCreation()
diff --git a/hibernate-core/src/main/java/org/hibernate/event/spi/PostLoadEvent.java b/hibernate-core/src/main/java/org/hibernate/event/spi/PostLoadEvent.java
index ca4aaedc73..fe0072068a 100644
--- a/hibernate-core/src/main/java/org/hibernate/event/spi/PostLoadEvent.java
+++ b/hibernate-core/src/main/java/org/hibernate/event/spi/PostLoadEvent.java
@@ -24,6 +24,12 @@ public class PostLoadEvent extends AbstractEvent {
super(session);
}
+ public void reset() {
+ entity = null;
+ id = null;
+ persister = null;
+ }
+
public Object getEntity() {
return entity;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/event/spi/PreLoadEvent.java b/hibernate-core/src/main/java/org/hibernate/event/spi/PreLoadEvent.java
index 8673d8b375..35664ea19a 100644
--- a/hibernate-core/src/main/java/org/hibernate/event/spi/PreLoadEvent.java
+++ b/hibernate-core/src/main/java/org/hibernate/event/spi/PreLoadEvent.java
@@ -26,6 +26,13 @@ public class PreLoadEvent extends AbstractEvent implements PermissionCheckEntity
super(session);
}
+ public void reset() {
+ entity = null;
+ state = null;
+ id = null;
+ persister = null;
+ }
+
@Override
public Object getEntity() {
return entity;
diff --git a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java
index 012cc9fbc9..ded3258d81 100644
--- a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java
+++ b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java
@@ -34,10 +34,7 @@ import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.SessionEventListener;
import org.hibernate.SessionException;
import org.hibernate.Transaction;
-import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.cache.spi.CacheTransactionSynchronization;
-import org.hibernate.cfg.Environment;
-import org.hibernate.dialect.Dialect;
import org.hibernate.engine.internal.SessionEventListenerManagerImpl;
import org.hibernate.engine.jdbc.LobCreationContext;
import org.hibernate.engine.jdbc.LobCreator;
@@ -645,12 +642,10 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
@Override
public NativeQueryImplementor createNativeQuery(String sqlString) {
- return getNativeQueryImplementor( sqlString, false );
+ return getNativeQueryImplementor( sqlString );
}
- protected NativeQueryImplementor getNativeQueryImplementor(
- String queryString,
- boolean isOrdinalParameterZeroBased) {
+ protected NativeQueryImplementor getNativeQueryImplementor(String queryString) {
checkOpen();
pulseTransactionCoordinator();
delayedAfterCompletion();
diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java
index dccb07d5fb..a99c72969e 100644
--- a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java
@@ -33,7 +33,6 @@ import javax.persistence.EntityNotFoundException;
import javax.persistence.FlushModeType;
import javax.persistence.LockModeType;
import javax.persistence.PersistenceException;
-import javax.persistence.PessimisticLockScope;
import javax.persistence.StoredProcedureQuery;
import javax.persistence.TransactionRequiredException;
@@ -1377,7 +1376,7 @@ public final class SessionImpl
pulseTransactionCoordinator();
Object result = getInterceptor().instantiate(
persister.getEntityName(),
- persister.getEntityMetamodel().getEntityMode(),
+ persister.getRepresentationStrategy(),
id
);
if ( result == null ) {
diff --git a/hibernate-core/src/main/java/org/hibernate/internal/log/LoggingHelper.java b/hibernate-core/src/main/java/org/hibernate/internal/log/LoggingHelper.java
new file mode 100644
index 0000000000..c99327ed45
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/internal/log/LoggingHelper.java
@@ -0,0 +1,101 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * License: GNU Lesser General Public License (LGPL), version 2.1 or later
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
+ */
+package org.hibernate.internal.log;
+
+import org.hibernate.collection.spi.PersistentCollection;
+import org.hibernate.engine.spi.CollectionKey;
+import org.hibernate.engine.spi.EntityKey;
+import org.hibernate.internal.util.StringHelper;
+import org.hibernate.metamodel.model.domain.NavigableRole;
+import org.hibernate.query.NavigablePath;
+
+/**
+ * Helper for logging collection, entity and embeddable information. Uses path collapsing
+ * for readability
+ *
+ * @author Steve Ebersole
+ */
+public class LoggingHelper {
+ private static final String NULL = "";
+ private static final String UNREFERENCED = "";
+
+ public static String toLoggableString(NavigableRole role) {
+ if ( role == null ) {
+ return UNREFERENCED;
+ }
+
+ if ( role.isRoot() ) {
+ return StringHelper.collapse( role.getFullPath() );
+ }
+ else {
+ assert role.getParent() != null;
+ return StringHelper.collapse( role.getParent().getFullPath() ) + '.' + role.getNavigableName();
+ }
+ }
+
+ public static String toLoggableString(NavigablePath path) {
+ assert path != null;
+
+ if ( path.isRoot() ) {
+ return StringHelper.collapse( path.getFullPath() );
+ }
+ else {
+ assert path.getParent() != null;
+ return StringHelper.collapse( path.getParent().getFullPath() ) + '.' + path.getLocalName();
+ }
+ }
+
+ public static String toLoggableString(NavigableRole role, Object key) {
+ if ( role == null ) {
+ return UNREFERENCED;
+ }
+
+ return toLoggableString( toLoggableString( role ), key );
+ }
+
+ public static String toLoggableString(NavigablePath path, Object key) {
+ assert path != null;
+ return toLoggableString( toLoggableString( path ), key );
+ }
+
+ public static String toLoggableString(CollectionKey collectionKey) {
+ return toLoggableString( collectionKey.getRole(), collectionKey.getKey() );
+ }
+
+ public static String toLoggableString(EntityKey entityKey) {
+ return toLoggableString( StringHelper.collapse( entityKey.getEntityName() ), entityKey.getIdentifierValue() );
+ }
+
+ private static String toLoggableString(String roleOrPath, Object key) {
+ assert roleOrPath != null;
+
+ StringBuilder buffer = new StringBuilder();
+
+ buffer.append( roleOrPath );
+ buffer.append( '#' );
+
+ if ( key == null ) {
+ buffer.append( NULL );
+ }
+ else {
+ buffer.append( key );
+ }
+
+ return buffer.toString();
+ }
+
+ public static String toLoggableString(PersistentCollection collectionInstance) {
+ if ( collectionInstance == null ) {
+ return NULL;
+ }
+
+ return toLoggableString(
+ collectionInstance.getRole(),
+ collectionInstance.getKey()
+ );
+ }
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/collections/CollectionHelper.java b/hibernate-core/src/main/java/org/hibernate/internal/util/collections/CollectionHelper.java
index e85e000931..c08303d9f5 100755
--- a/hibernate-core/src/main/java/org/hibernate/internal/util/collections/CollectionHelper.java
+++ b/hibernate-core/src/main/java/org/hibernate/internal/util/collections/CollectionHelper.java
@@ -212,4 +212,10 @@ public final class CollectionHelper {
public static boolean isEmpty(Object[] objects) {
return objects == null || objects.length == 0;
}
+
+ public static Set setOf(T... values) {
+ final HashSet set = new HashSet<>( determineProperSizing( values.length ) );
+ Collections.addAll( set, values );
+ return set;
+ }
}
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/RepresentationMode.java b/hibernate-core/src/main/java/org/hibernate/metamodel/RepresentationMode.java
index 62270d7c21..77e06a258f 100644
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/RepresentationMode.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/RepresentationMode.java
@@ -8,6 +8,8 @@ package org.hibernate.metamodel;
import java.util.Locale;
+import org.hibernate.EntityMode;
+
/**
* Enumeration of the built-in ways that Hibernate can represent the
* application's domain model.
@@ -15,25 +17,33 @@ import java.util.Locale;
* @author Steve Ebersole
*/
public enum RepresentationMode {
- POJO( "pojo" ),
- MAP( "map", "dynamic-map" );
+ POJO( "pojo", EntityMode.POJO ),
+ MAP( "map", "dynamic-map", EntityMode.MAP );
private final String externalName;
private final String alternativeExternalName;
- RepresentationMode(String externalName) {
- this ( externalName, null );
+ private final EntityMode legacyEntityMode;
+
+ RepresentationMode(String externalName, EntityMode legacyEntityMode) {
+ this ( externalName, null, legacyEntityMode );
}
- RepresentationMode(String externalName, String alternativeExternalName) {
+ RepresentationMode(String externalName, String alternativeExternalName, EntityMode legacyEntityMode) {
this.externalName = externalName;
this.alternativeExternalName = alternativeExternalName;
+ this.legacyEntityMode = legacyEntityMode;
}
public String getExternalName() {
return externalName;
}
+ @Deprecated
+ public EntityMode getLegacyEntityMode() {
+ return legacyEntityMode;
+ }
+
public static RepresentationMode fromExternalName(String externalName) {
if ( externalName == null ) {
return POJO;
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/AttributeFactory.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/AttributeFactory.java
index 9d9134c517..b296e5ffbb 100755
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/AttributeFactory.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/AttributeFactory.java
@@ -43,6 +43,7 @@ import org.hibernate.metamodel.model.domain.internal.MappedSuperclassTypeImpl;
import org.hibernate.metamodel.model.domain.internal.PluralAttributeBuilder;
import org.hibernate.metamodel.model.domain.internal.SingularAttributeImpl;
import org.hibernate.metamodel.spi.ManagedTypeRepresentationStrategy;
+import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.property.access.internal.PropertyAccessMapImpl;
import org.hibernate.property.access.spi.Getter;
import org.hibernate.tuple.entity.EntityMetamodel;
@@ -289,6 +290,24 @@ public class AttributeFactory {
return getDeclarerEntityMetamodel( ownerType, context );
}
+ private static EntityPersister getDeclaringEntity(
+ AbstractIdentifiableType> ownerType,
+ MetadataContext metadataContext) {
+ final Type.PersistenceType persistenceType = ownerType.getPersistenceType();
+ if ( persistenceType == Type.PersistenceType.ENTITY ) {
+ return metadataContext.getMetamodel()
+ .getEntityDescriptor( ownerType.getTypeName() );
+ }
+ else if ( persistenceType == Type.PersistenceType.MAPPED_SUPERCLASS ) {
+ PersistentClass persistentClass =
+ metadataContext.getPersistentClassHostingProperties( (MappedSuperclassTypeImpl>) ownerType );
+ return metadataContext.getMetamodel()
+ .findEntityDescriptor( persistentClass.getClassName() );
+ }
+ else {
+ throw new AssertionFailure( "Cannot get the metamodel for PersistenceType: " + persistenceType );
+ }
+ }
private static EntityMetamodel getDeclarerEntityMetamodel(
AbstractIdentifiableType> ownerType,
MetadataContext metadataContext) {
@@ -609,7 +628,8 @@ public class AttributeFactory {
else if ( Type.PersistenceType.ENTITY == persistenceType
|| Type.PersistenceType.MAPPED_SUPERCLASS == persistenceType ) {
final AbstractIdentifiableType identifiableType = (AbstractIdentifiableType) ownerType;
- final EntityMetamodel entityMetamodel = getDeclarerEntityMetamodel( identifiableType, metadataContext );
+ final EntityPersister declaringEntityMapping = getDeclaringEntity( identifiableType, metadataContext );
+ final EntityMetamodel entityMetamodel = declaringEntityMapping.getEntityMetamodel();
final String propertyName = property.getName();
final Integer index = entityMetamodel.getPropertyIndexOrNull( propertyName );
if ( index == null ) {
@@ -617,7 +637,7 @@ public class AttributeFactory {
return virtualIdentifierMemberResolver.resolveMember( attributeContext, metadataContext );
}
else {
- final Getter getter = entityMetamodel.getTuplizer().getGetter( index );
+ final Getter getter = declaringEntityMapping.getRepresentationStrategy().resolvePropertyAccess( property ).getGetter();
return getter instanceof PropertyAccessMapImpl.GetterImpl
? new MapMember( propertyName, property.getType().getReturnedClass() )
: getter.getMember();
@@ -630,14 +650,17 @@ public class AttributeFactory {
private final MemberResolver identifierMemberResolver = (attributeContext, metadataContext) -> {
final AbstractIdentifiableType identifiableType = (AbstractIdentifiableType) attributeContext.getOwnerType();
- final EntityMetamodel entityMetamodel = getDeclarerEntityMetamodel( identifiableType );
+ final EntityPersister declaringEntityMapping = getDeclaringEntity( identifiableType, metadataContext );
+ final EntityMetamodel entityMetamodel = declaringEntityMapping.getEntityMetamodel();
+
if ( !attributeContext.getPropertyMapping().getName()
.equals( entityMetamodel.getIdentifierProperty().getName() ) ) {
// this *should* indicate processing part of an IdClass...
return virtualIdentifierMemberResolver.resolveMember( attributeContext, metadataContext );
}
- final Getter getter = entityMetamodel.getTuplizer().getIdentifierGetter();
- if ( PropertyAccessMapImpl.GetterImpl.class.isInstance( getter ) ) {
+
+ final Getter getter = declaringEntityMapping.getRepresentationStrategy().resolvePropertyAccess( attributeContext.getPropertyMapping() ).getGetter();
+ if ( getter instanceof PropertyAccessMapImpl.GetterImpl ) {
return new MapMember(
entityMetamodel.getIdentifierProperty().getName(),
entityMetamodel.getIdentifierProperty().getType().getReturnedClass()
@@ -654,14 +677,15 @@ public class AttributeFactory {
AttributeContext attributeContext,
MetadataContext metadataContext) {
final AbstractIdentifiableType identifiableType = (AbstractIdentifiableType) attributeContext.getOwnerType();
- final EntityMetamodel entityMetamodel = getDeclarerEntityMetamodel( identifiableType );
+ final EntityPersister declaringEntityMapping = getDeclaringEntity( identifiableType, metadataContext );
+ final EntityMetamodel entityMetamodel = declaringEntityMapping.getEntityMetamodel();
final String versionPropertyName = attributeContext.getPropertyMapping().getName();
if ( !versionPropertyName.equals( entityMetamodel.getVersionProperty().getName() ) ) {
// this should never happen, but to be safe...
throw new IllegalArgumentException( "Given property did not match declared version property" );
}
- final Getter getter = entityMetamodel.getTuplizer().getVersionGetter();
+ final Getter getter = declaringEntityMapping.getRepresentationStrategy().resolvePropertyAccess( attributeContext.getPropertyMapping() ).getGetter();
if ( PropertyAccessMapImpl.GetterImpl.class.isInstance( getter ) ) {
return new MapMember(
versionPropertyName,
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/DynamicMapInstantiator.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/DynamicMapInstantiator.java
index ad5426a5ee..b1e1441748 100644
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/DynamicMapInstantiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/DynamicMapInstantiator.java
@@ -12,6 +12,8 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Set;
+import org.hibernate.EntityNameResolver;
+import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.mapping.Component;
@@ -22,6 +24,17 @@ import org.hibernate.metamodel.spi.Instantiator;
* @author Steve Ebersole
*/
public class DynamicMapInstantiator implements Instantiator