clean up the MappingMetamodel interface
- deprecate some operations - remove some already-deprecated operations
This commit is contained in:
parent
9a219c2c30
commit
d784d6a808
|
@ -757,7 +757,7 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
|
|||
}
|
||||
}
|
||||
);
|
||||
runtimeMetamodels.getMappingMetamodel().close();
|
||||
// runtimeMetamodels.getMappingMetamodel().close();
|
||||
}
|
||||
|
||||
if ( queryEngine != null ) {
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.function.Function;
|
|||
import java.util.stream.Stream;
|
||||
|
||||
import org.hibernate.Incubating;
|
||||
import org.hibernate.Internal;
|
||||
import org.hibernate.graph.RootGraph;
|
||||
import org.hibernate.graph.spi.RootGraphImplementor;
|
||||
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
|
||||
|
@ -42,6 +43,7 @@ public interface MappingMetamodel extends Metamodel {
|
|||
// SQM model -> Mapping model
|
||||
|
||||
// todo (6.0) : POC intended for use in SQM to SQL translation
|
||||
@Internal
|
||||
MappingModelExpressible<?> resolveMappingExpressible(
|
||||
SqmExpressible<?> sqmExpressible,
|
||||
Function<NavigablePath,
|
||||
|
@ -61,6 +63,8 @@ public interface MappingMetamodel extends Metamodel {
|
|||
* Visit all entity mapping descriptors defined in the model
|
||||
*/
|
||||
void forEachEntityDescriptor(Consumer<EntityPersister> action);
|
||||
|
||||
@Deprecated(forRemoval = true, since = "7")
|
||||
Stream<EntityPersister> streamEntityDescriptors();
|
||||
|
||||
/**
|
||||
|
@ -123,31 +127,12 @@ public interface MappingMetamodel extends Metamodel {
|
|||
* direct entity name.
|
||||
*
|
||||
* @throws org.hibernate.UnknownEntityTypeException If a matching EntityPersister cannot be located
|
||||
*
|
||||
* @deprecated No longer used
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "7")
|
||||
EntityPersister locateEntityDescriptor(Class<?> byClass);
|
||||
|
||||
/**
|
||||
* @see #locateEntityDescriptor
|
||||
*
|
||||
* @deprecated use {@link #locateEntityDescriptor(Class)} instead
|
||||
*/
|
||||
@Deprecated(since = "6.0")
|
||||
default EntityPersister locateEntityPersister(Class<?> byClass) {
|
||||
return locateEntityDescriptor( byClass );
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate the entity persister by name.
|
||||
*
|
||||
* @return The located EntityPersister, never {@code null}
|
||||
*
|
||||
* @throws org.hibernate.UnknownEntityTypeException If a matching EntityPersister cannot be located
|
||||
*
|
||||
* @deprecated - use {@link #getEntityDescriptor(String)} instead
|
||||
*/
|
||||
@Deprecated(since = "6.0")
|
||||
EntityPersister locateEntityPersister(String byName);
|
||||
|
||||
String getImportedName(String name);
|
||||
|
||||
|
||||
|
@ -158,6 +143,8 @@ public interface MappingMetamodel extends Metamodel {
|
|||
* Visit the mapping descriptors for all collections defined in the model
|
||||
*/
|
||||
void forEachCollectionDescriptor(Consumer<CollectionPersister> action);
|
||||
|
||||
@Deprecated(forRemoval = true, since = "7")
|
||||
Stream<CollectionPersister> streamCollectionDescriptors();
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,8 +21,6 @@ import org.hibernate.EntityNameResolver;
|
|||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.UnknownEntityTypeException;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.cache.spi.CacheImplementor;
|
||||
import org.hibernate.cache.spi.access.CollectionDataAccess;
|
||||
|
@ -104,8 +102,6 @@ public class MappingMetamodelImpl extends QueryParameterBindingTypeResolverImpl
|
|||
//NOTE: we suppress deprecation warnings because at the moment we
|
||||
//implement a deprecated API so have to override deprecated things
|
||||
|
||||
private static final String[] EMPTY_IMPLEMENTORS = EMPTY_STRING_ARRAY;
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// JpaMetamodel
|
||||
|
||||
|
@ -145,22 +141,8 @@ public class MappingMetamodelImpl extends QueryParameterBindingTypeResolverImpl
|
|||
//
|
||||
// To account for this, we track both paradigms here...
|
||||
|
||||
/*
|
||||
* There can be multiple instances of an Embeddable type, each one being relative to its parent entity.
|
||||
*/
|
||||
// There can be multiple instances of an Embeddable type, each one being relative to its parent entity.
|
||||
|
||||
/**
|
||||
* That's not strictly correct in the JPA standard since for a given Java type we could have
|
||||
* multiple instances of an embeddable type. Some embeddable might override attributes, but we
|
||||
* can only return a single EmbeddableTypeImpl for a given Java object class.
|
||||
* <p>
|
||||
* A better approach would be if the parent class and attribute name would be included as well
|
||||
* when trying to locate the embeddable type.
|
||||
*/
|
||||
// private final Map<Class<?>, EmbeddableDomainType<?>> jpaEmbeddableTypeMap = new ConcurrentHashMap<>();
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
private final Map<String, String[]> implementorsCache = new ConcurrentHashMap<>();
|
||||
private final Map<TupleType<?>, MappingModelExpressible<?>> tupleTypeCache = new ConcurrentHashMap<>();
|
||||
|
||||
public MappingMetamodelImpl(TypeConfiguration typeConfiguration, ServiceRegistry serviceRegistry) {
|
||||
|
@ -370,7 +352,7 @@ public class MappingMetamodelImpl extends QueryParameterBindingTypeResolverImpl
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @Deprecated(forRemoval=true) @SuppressWarnings( "removal" )
|
||||
public Stream<EntityPersister> streamEntityDescriptors() {
|
||||
return Arrays.stream( entityPersisterMap.values() );
|
||||
}
|
||||
|
@ -430,7 +412,7 @@ public class MappingMetamodelImpl extends QueryParameterBindingTypeResolverImpl
|
|||
return entityPersister;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @Deprecated(forRemoval = true) @SuppressWarnings( "removal" )
|
||||
public EntityPersister locateEntityDescriptor(Class<?> byClass) {
|
||||
EntityPersister entityPersister = entityPersisterMap.get( byClass.getName() );
|
||||
if ( entityPersister == null ) {
|
||||
|
@ -542,43 +524,6 @@ public class MappingMetamodelImpl extends QueryParameterBindingTypeResolverImpl
|
|||
return jpaMetamodel.enumValue( enumType, enumValueName );
|
||||
}
|
||||
|
||||
public String[] getImplementors(String className) throws MappingException {
|
||||
// computeIfAbsent() can be a contention point and we expect all the values to be in the map at some point so
|
||||
// let's do an optimistic check first
|
||||
String[] implementors = implementorsCache.get( className );
|
||||
if ( implementors != null ) {
|
||||
return Arrays.copyOf( implementors, implementors.length );
|
||||
}
|
||||
|
||||
try {
|
||||
final Class<?> clazz =
|
||||
jpaMetamodel.getServiceRegistry().requireService( ClassLoaderService.class )
|
||||
.classForName( className );
|
||||
implementors = doGetImplementors( clazz );
|
||||
if ( implementors.length > 0 ) {
|
||||
implementorsCache.putIfAbsent( className, implementors );
|
||||
return Arrays.copyOf( implementors, implementors.length );
|
||||
}
|
||||
else {
|
||||
return EMPTY_IMPLEMENTORS;
|
||||
}
|
||||
}
|
||||
catch (ClassLoadingException e) {
|
||||
return new String[] { className }; // we don't cache anything for dynamic classes
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public EntityPersister locateEntityPersister(String byName) {
|
||||
final EntityPersister entityPersister = entityPersisterMap.get( byName );
|
||||
if ( entityPersister == null ) {
|
||||
throw new UnknownEntityTypeException( "Unable to locate persister: " + byName );
|
||||
}
|
||||
return entityPersister;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getImportedName(String name) {
|
||||
final String qualifiedName = jpaMetamodel.qualifyImportableName( name );
|
||||
|
@ -590,7 +535,7 @@ public class MappingMetamodelImpl extends QueryParameterBindingTypeResolverImpl
|
|||
collectionPersisterMap.values().forEach( action );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @Deprecated(forRemoval=true) @SuppressWarnings( "removal" )
|
||||
public Stream<CollectionPersister> streamCollectionDescriptors() {
|
||||
return collectionPersisterMap.values().stream();
|
||||
}
|
||||
|
@ -847,9 +792,4 @@ public class MappingMetamodelImpl extends QueryParameterBindingTypeResolverImpl
|
|||
public String[] getAllCollectionRoles() {
|
||||
return ArrayHelper.toStringArray( collectionPersisterMap.keySet() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// anything to do ?
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,9 +55,4 @@ public interface MappingMetamodelImplementor extends MappingMetamodel, QueryPara
|
|||
.map( CollectionPersister::getRole )
|
||||
.toArray( String[]::new );
|
||||
}
|
||||
|
||||
default void close() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class EntityNonEntityTest extends BaseCoreFunctionalTestCase {
|
|||
@JiraKey( value = "HHH-9856" )
|
||||
public void testGetAndFindNonEntityThrowsIllegalArgumentException() {
|
||||
try {
|
||||
sessionFactory().getMappingMetamodel().locateEntityPersister(Cellular.class);
|
||||
sessionFactory().getMappingMetamodel().findEntityDescriptor(Cellular.class);
|
||||
sessionFactory().getRuntimeMetamodels().getMappingMetamodel().getEntityDescriptor( Cellular.class );
|
||||
|
||||
}
|
||||
|
|
|
@ -701,12 +701,6 @@ public abstract class MockSessionFactory
|
|||
return createEntityPersister(entityName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPersister locateEntityPersister(String entityName)
|
||||
throws MappingException {
|
||||
return createEntityPersister(entityName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CollectionPersister getCollectionDescriptor(String role) {
|
||||
return createCollectionPersister(role);
|
||||
|
|
Loading…
Reference in New Issue