HHH-14770 Revert "HHH-14770 Optimise access to EntityPersister in Metamodel via Class type"
This reverts commit 9a335c1c04
.
This commit is contained in:
parent
fb0279e3a7
commit
544dbbf762
|
@ -167,12 +167,12 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
|||
|
||||
@Override
|
||||
public Object get(Class entityClass, Serializable id) {
|
||||
return get( entityClass, id, LockMode.NONE );
|
||||
return get( entityClass.getName(), id );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(Class entityClass, Serializable id, LockMode lockMode) {
|
||||
return get( getFactory().getMetamodel().entityPersister( entityClass ), id, lockMode );
|
||||
return get( entityClass.getName(), id, lockMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -182,13 +182,10 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
|||
|
||||
@Override
|
||||
public Object get(String entityName, Serializable id, LockMode lockMode) {
|
||||
return get( getFactory().getMetamodel().entityPersister( entityName ), id, lockMode );
|
||||
}
|
||||
|
||||
protected Object get(final EntityPersister ep, final Serializable id, final LockMode lockMode) {
|
||||
checkOpen();
|
||||
|
||||
Object result = ep.load( id, null, getNullSafeLockMode( lockMode ), this );
|
||||
Object result = getFactory().getMetamodel().entityPersister( entityName )
|
||||
.load( id, null, getNullSafeLockMode( lockMode ), this );
|
||||
if ( temporaryPersistenceContext.isLoadFinished() ) {
|
||||
temporaryPersistenceContext.clear();
|
||||
}
|
||||
|
@ -499,7 +496,7 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
|||
throws HibernateException {
|
||||
checkOpen();
|
||||
if ( entityName == null ) {
|
||||
return getFactory().getMetamodel().entityPersister( object.getClass() );
|
||||
return getFactory().getMetamodel().entityPersister( guessEntityName( object ) );
|
||||
}
|
||||
else {
|
||||
return getFactory().getMetamodel().entityPersister( entityName ).getSubclassEntityPersister( object, getFactory() );
|
||||
|
|
|
@ -142,29 +142,6 @@ public class MetamodelImpl implements MetamodelImplementor, Serializable {
|
|||
|
||||
private final Map<String, String[]> implementorsCache = new ConcurrentHashMap<>();
|
||||
|
||||
// EntityPersister by Class is very hot: optimize access with a ClassValue
|
||||
private final ClassValue<EntityPersister> entityPersisterMapByClass = new ClassValue() {
|
||||
@Override
|
||||
protected EntityPersister computeValue(final Class type) {
|
||||
return entityPersisterMap.get( type.getName() );
|
||||
}
|
||||
};
|
||||
|
||||
// "full location" of an EntityPersister by Class is also hot: optimize access with a ClassValue
|
||||
private final ClassValue<EntityPersister> locateEntityPersisterMapByClass = new ClassValue() {
|
||||
@Override
|
||||
protected EntityPersister computeValue(final Class type) {
|
||||
EntityPersister entityPersister = entityPersisterMapByClass.get( type );
|
||||
if ( entityPersister == null ) {
|
||||
String mappedEntityName = entityProxyInterfaceMap.get( type );
|
||||
if ( mappedEntityName != null ) {
|
||||
entityPersister = entityPersisterMap.get( mappedEntityName );
|
||||
}
|
||||
}
|
||||
return entityPersister;
|
||||
}
|
||||
};
|
||||
|
||||
public MetamodelImpl(SessionFactoryImplementor sessionFactory, TypeConfiguration typeConfiguration) {
|
||||
this.sessionFactory = sessionFactory;
|
||||
this.typeConfiguration = typeConfiguration;
|
||||
|
@ -717,7 +694,7 @@ public class MetamodelImpl implements MetamodelImplementor, Serializable {
|
|||
|
||||
@Override
|
||||
public EntityPersister entityPersister(Class entityClass) {
|
||||
return entityPersisterMapByClass.get( entityClass );
|
||||
return entityPersister( entityClass.getName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -729,12 +706,21 @@ public class MetamodelImpl implements MetamodelImplementor, Serializable {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EntityPersister locateEntityPersister(final Class byClass) {
|
||||
EntityPersister entityPersister = locateEntityPersisterMapByClass.get( byClass );
|
||||
public EntityPersister locateEntityPersister(Class byClass) {
|
||||
EntityPersister entityPersister = entityPersisterMap.get( byClass.getName() );
|
||||
if ( entityPersister == null ) {
|
||||
String mappedEntityName = entityProxyInterfaceMap.get( byClass );
|
||||
if ( mappedEntityName != null ) {
|
||||
entityPersister = entityPersisterMap.get( mappedEntityName );
|
||||
}
|
||||
}
|
||||
|
||||
if ( entityPersister == null ) {
|
||||
throw new UnknownEntityTypeException( "Unable to locate persister: " + byClass.getName() );
|
||||
}
|
||||
|
||||
return entityPersister;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue