HHH-10664 - Prep 6.0 feature branch - merge hibernate-entitymanager into hibernate-core (continued fixing of hibernate-core test failures)

This commit is contained in:
Steve Ebersole 2016-04-26 10:57:29 -05:00
parent 5c5de945e5
commit 59ed7fa29b
10 changed files with 31 additions and 39 deletions

View File

@ -163,7 +163,13 @@ public interface SessionFactoryImplementor extends Mapping, SessionFactory, Quer
*/
CurrentTenantIdentifierResolver getCurrentTenantIdentifierResolver();
Iterable<EntityNameResolver> iterateEntityNameResolvers();
/**
* @deprecated (since 5.2) use {@link #getMetamodel()} -> {@link MetamodelImplementor#getEntityNameResolvers()}
*/
@Deprecated
default Iterable<EntityNameResolver> iterateEntityNameResolvers() {
return getMetamodel().getEntityNameResolvers();
}
/**
* Contract for resolving this SessionFactory on deserialization

View File

@ -29,7 +29,7 @@ public class CoordinatingEntityNameResolver implements EntityNameResolver {
return entityName;
}
for ( EntityNameResolver resolver : sessionFactory.iterateEntityNameResolvers() ) {
for ( EntityNameResolver resolver : sessionFactory.getMetamodel().getEntityNameResolvers() ) {
entityName = resolver.resolveEntityName( entity );
if ( entityName != null ) {
break;

View File

@ -18,8 +18,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import javax.naming.Reference;
import javax.naming.StringRefAddr;
import javax.persistence.EntityGraph;
@ -35,7 +33,6 @@ import org.hibernate.ConnectionAcquisitionMode;
import org.hibernate.ConnectionReleaseMode;
import org.hibernate.CustomEntityDirtinessStrategy;
import org.hibernate.EmptyInterceptor;
import org.hibernate.EntityNameResolver;
import org.hibernate.FlushMode;
import org.hibernate.HibernateException;
import org.hibernate.Interceptor;
@ -118,7 +115,6 @@ import org.hibernate.service.spi.SessionFactoryServiceRegistryFactory;
import org.hibernate.stat.spi.StatisticsImplementor;
import org.hibernate.tool.schema.spi.DelayedDropAction;
import org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator;
import org.hibernate.tuple.entity.EntityTuplizer;
import org.hibernate.type.SerializableType;
import org.hibernate.type.Type;
import org.hibernate.type.TypeResolver;
@ -184,7 +180,6 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
private final transient Map<String,IdentifierGenerator> identifierGenerators;
private final transient Map<String, FilterDefinition> filters;
private final transient Map<String, FetchProfile> fetchProfiles;
private final transient ConcurrentMap<EntityNameResolver,Object> entityNameResolvers = new ConcurrentHashMap<>();
private final transient TypeResolver typeResolver;
private final transient TypeHelper typeHelper;
@ -498,35 +493,6 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
return typeResolver;
}
private void registerEntityNameResolvers(EntityPersister persister) {
if ( persister.getEntityMetamodel() == null || persister.getEntityMetamodel().getTuplizer() == null ) {
return;
}
registerEntityNameResolvers( persister.getEntityMetamodel().getTuplizer() );
}
private void registerEntityNameResolvers(EntityTuplizer tuplizer) {
EntityNameResolver[] resolvers = tuplizer.getEntityNameResolvers();
if ( resolvers == null ) {
return;
}
for ( EntityNameResolver resolver : resolvers ) {
registerEntityNameResolver( resolver );
}
}
private static final Object ENTITY_NAME_RESOLVER_MAP_VALUE = new Object();
public void registerEntityNameResolver(EntityNameResolver resolver) {
entityNameResolvers.put( resolver, ENTITY_NAME_RESOLVER_MAP_VALUE );
}
@Override
public Iterable<EntityNameResolver> iterateEntityNameResolvers() {
return entityNameResolvers.keySet();
}
public QueryPlanCache getQueryPlanCache() {
return queryPlanCache;
}

View File

@ -209,6 +209,7 @@ public class MetamodelImpl implements MetamodelImplementor, Serializable {
this.jpaEntityTypesByEntityName.putAll( context.getEntityTypesByEntityName() );
}
@Override
public java.util.Collection<EntityNameResolver> getEntityNameResolvers() {
return entityNameResolvers.keySet();
}

View File

@ -6,9 +6,11 @@
*/
package org.hibernate.metamodel.spi;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import org.hibernate.EntityNameResolver;
import org.hibernate.MappingException;
import org.hibernate.Metamodel;
import org.hibernate.engine.spi.SessionFactoryImplementor;
@ -22,6 +24,8 @@ public interface MetamodelImplementor extends Metamodel {
@Override
SessionFactoryImplementor getSessionFactory();
Collection<EntityNameResolver> getEntityNameResolvers();
/**
* Locate an EntityPersister by the entity class. The passed Class might refer to either
* the entity name directly, or it might name a proxy interface for the entity. This

View File

@ -18,6 +18,8 @@ import org.hibernate.type.Type;
public class QueryParameterBindingImpl<T> implements QueryParameterBinding<T> {
private final QueryParameterBindingTypeResolver typeResolver;
private boolean isBound;
private Type bindType;
private T bindValue;
@ -26,6 +28,11 @@ public class QueryParameterBindingImpl<T> implements QueryParameterBinding<T> {
this.typeResolver = typeResolver;
}
@Override
public boolean isBound() {
return isBound;
}
@Override
public T getBindValue() {
return bindValue;
@ -38,6 +45,7 @@ public class QueryParameterBindingImpl<T> implements QueryParameterBinding<T> {
@Override
public void setBindValue(T value) {
this.isBound = true;
this.bindValue = value;
if ( bindType == null ) {

View File

@ -194,8 +194,8 @@ public class QueryParameterBindingsImpl implements QueryParameterBindings {
public void verifyParametersBound(boolean reserveFirstParameter) {
for ( Map.Entry<QueryParameter, QueryParameterBinding> bindEntry : parameterBindingMap.entrySet() ) {
if ( bindEntry.getValue().getBindValue() == null ) {
if ( bindEntry.getKey().getName() == null ) {
if ( !bindEntry.getValue().isBound() ) {
if ( bindEntry.getKey().getName() != null ) {
throw new QueryException( "Named parameter [" + bindEntry.getKey().getName() + "] not set" );
}
else if ( bindEntry.getKey().getPosition() != null ) {

View File

@ -22,6 +22,11 @@ public class ProcedureParameterBindingImpl<T> implements ProcedureParameterBindi
this.parameter = parameter;
}
@Override
public boolean isBound() {
return parameter.getNativeParameterRegistration().getBind() != null;
}
@Override
public void setBindValue(T value) {
parameter.getNativeParameterRegistration().bindValue( value );

View File

@ -18,6 +18,8 @@ import org.hibernate.type.Type;
*/
@Incubating
public interface QueryParameterBinding<T> {
boolean isBound();
/**
* Sets the parameter binding value. The inherent parameter type (if known) is assumed
*

View File

@ -178,7 +178,7 @@ public class AnyType extends AbstractType implements CompositeType, AssociationT
}
if ( entityName == null ) {
for ( EntityNameResolver resolver : scope.resolveFactory().iterateEntityNameResolvers() ) {
for ( EntityNameResolver resolver : scope.resolveFactory().getMetamodel().getEntityNameResolvers() ) {
entityName = resolver.resolveEntityName( entity );
if ( entityName != null ) {
break;