6 - SQM based on JPA type system, RuntimeModelCreationProcess
This commit is contained in:
parent
52aff8055e
commit
638c217e8a
|
@ -75,6 +75,7 @@ public class InflightRuntimeMetamodel {
|
|||
|
||||
private final Map<String, String> nameToImportNameMap = new HashMap<>();
|
||||
private final Set<EntityNameResolver> entityNameResolvers = new CopyOnWriteArraySet<>();
|
||||
private final Map<String, String> imports = new ConcurrentHashMap<>( );
|
||||
|
||||
public InflightRuntimeMetamodel(TypeConfiguration typeConfiguration) {
|
||||
this.typeConfiguration = typeConfiguration;
|
||||
|
@ -88,6 +89,7 @@ public class InflightRuntimeMetamodel {
|
|||
PersisterCreationContext persisterCreationContext,
|
||||
JpaMetaModelPopulationSetting jpaMetaModelPopulationSetting,
|
||||
JpaStaticMetaModelPopulationSetting jpaStaticMetaModelPopulationSetting) {
|
||||
this.imports.putAll( bootMetamodel.getImports() );
|
||||
processBootEntities(
|
||||
bootMetamodel.getEntityBindings(),
|
||||
cacheImplementor,
|
||||
|
@ -424,4 +426,7 @@ public class InflightRuntimeMetamodel {
|
|||
return entityType;
|
||||
}
|
||||
|
||||
public Map<String, String> getImports() {
|
||||
return imports;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import javax.persistence.metamodel.ManagedType;
|
|||
|
||||
import org.hibernate.EntityNameResolver;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.UnknownEntityTypeException;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
||||
|
@ -35,6 +36,7 @@ import org.hibernate.metamodel.model.domain.EmbeddableDomainType;
|
|||
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
||||
import org.hibernate.metamodel.model.domain.JpaMetamodel;
|
||||
import org.hibernate.metamodel.model.domain.ManagedDomainType;
|
||||
import org.hibernate.metamodel.model.domain.NavigableRole;
|
||||
import org.hibernate.metamodel.spi.DomainMetamodel;
|
||||
import org.hibernate.metamodel.spi.MetamodelImplementor;
|
||||
import org.hibernate.persister.collection.CollectionPersister;
|
||||
|
@ -53,7 +55,6 @@ public class DomainMetamodelImpl implements DomainMetamodel, MetamodelImplemento
|
|||
// todo : Integrate EntityManagerLogger into CoreMessageLogger
|
||||
private static final EntityManagerMessageLogger log = HEMLogging.messageLogger( DomainMetamodelImpl.class );
|
||||
|
||||
private static final Object ENTITY_NAME_RESOLVER_MAP_VALUE = new Object();
|
||||
private static final String INVALID_IMPORT = "";
|
||||
private static final String[] EMPTY_IMPLEMENTORS = new String[0];
|
||||
|
||||
|
@ -80,6 +81,8 @@ public class DomainMetamodelImpl implements DomainMetamodel, MetamodelImplemento
|
|||
|
||||
private final Set<EntityNameResolver> entityNameResolvers;
|
||||
|
||||
private final Map<String,String> imports;
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// NOTE : Relational/mapping information is not part of the JPA metamodel
|
||||
|
@ -129,6 +132,7 @@ public class DomainMetamodelImpl implements DomainMetamodel, MetamodelImplemento
|
|||
this.collectionRolesByEntityParticipant = runtimeMetamodel.getCollectionRolesByEntityParticipant();
|
||||
this.entityNameResolvers = runtimeMetamodel.getEntityNameResolvers();
|
||||
this.entityProxyInterfaceMap = runtimeMetamodel.getEntityProxyInterfaceMap();
|
||||
this.imports = runtimeMetamodel.getImports();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -157,6 +161,11 @@ public class DomainMetamodelImpl implements DomainMetamodel, MetamodelImplemento
|
|||
entityPersisterMap.values().forEach( action );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPersister resolveEntityDescriptor(EntityDomainType<?> entityDomainType) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPersister getEntityDescriptor(String entityName) {
|
||||
final EntityPersister entityPersister = entityPersisterMap.get( entityName );
|
||||
|
@ -166,6 +175,11 @@ public class DomainMetamodelImpl implements DomainMetamodel, MetamodelImplemento
|
|||
return entityPersister;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPersister getEntityDescriptor(NavigableRole name) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPersister findEntityDescriptor(String entityName) {
|
||||
return entityPersisterMap.get( entityName );
|
||||
|
@ -254,6 +268,29 @@ public class DomainMetamodelImpl implements DomainMetamodel, MetamodelImplemento
|
|||
return getJpaMetamodel().entity( entityName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getImportedClassName(String className) {
|
||||
String result = imports.get( className );
|
||||
if ( result == null ) {
|
||||
try {
|
||||
sessionFactory.getServiceRegistry().getService( ClassLoaderService.class ).classForName( className );
|
||||
imports.put( className, className );
|
||||
return className;
|
||||
}
|
||||
catch ( ClassLoadingException cnfe ) {
|
||||
imports.put( className, INVALID_IMPORT );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if ( result == INVALID_IMPORT ) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
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
|
||||
|
@ -323,6 +360,11 @@ public class DomainMetamodelImpl implements DomainMetamodel, MetamodelImplemento
|
|||
return entityPersister;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getImportedName(String name) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitCollectionDescriptors(Consumer<CollectionPersister> action) {
|
||||
collectionPersisterMap.values().forEach( action );
|
||||
|
@ -337,6 +379,16 @@ public class DomainMetamodelImpl implements DomainMetamodel, MetamodelImplemento
|
|||
return collectionPersister;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CollectionPersister getCollectionDescriptor(NavigableRole role) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public CollectionPersister findCollectionDescriptor(NavigableRole role) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public CollectionPersister findCollectionDescriptor(String role) {
|
||||
return collectionPersisterMap.get( role );
|
||||
|
@ -384,6 +436,46 @@ public class DomainMetamodelImpl implements DomainMetamodel, MetamodelImplemento
|
|||
return findEntityGraphByName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitNamedGraphs(Consumer<RootGraph<?>> action) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public RootGraph<?> defaultGraph(String entityName) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public RootGraph<?> defaultGraph(Class entityJavaType) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public RootGraph<?> defaultGraph(EntityPersister entityDescriptor) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public RootGraph<?> defaultGraph(EntityDomainType<?> entityDomainType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RootGraph<?>> findRootGraphsForType(Class baseEntityJavaType) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RootGraph<?>> findRootGraphsForType(String baseEntityName) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RootGraph<?>> findRootGraphsForType(EntityPersister baseEntityDescriptor) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// anything to do ?
|
||||
|
|
|
@ -56,7 +56,9 @@ public interface MetamodelImplementor extends DomainMetamodel, Metamodel {
|
|||
*
|
||||
* @throws org.hibernate.UnknownEntityTypeException If a matching EntityPersister cannot be located
|
||||
*/
|
||||
EntityPersister locateEntityPersister(Class byClass);
|
||||
default EntityPersister locateEntityPersister(Class byClass){
|
||||
return locateEntityDescriptor( byClass );
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate the entity persister by name.
|
||||
|
|
Loading…
Reference in New Issue