mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-28 14:59:12 +00:00
HHH-16661 Use qualified table names for entity name by table name map
This commit is contained in:
parent
53d474d85f
commit
bf1068be7e
@ -537,7 +537,8 @@ else if ( !elementType.isEntityType() ) {
|
||||
}
|
||||
else {
|
||||
entityNameByTableNameMap = AbstractEntityPersister.getEntityNameByTableNameMap(
|
||||
creationContext.getBootModel().getEntityBinding( elementPersister.getEntityName() )
|
||||
creationContext.getBootModel().getEntityBinding( elementPersister.getEntityName() ),
|
||||
factory.getSqlStringGenerationContext()
|
||||
);
|
||||
}
|
||||
filterHelper = new FilterHelper( collectionBootDescriptor.getFilters(), entityNameByTableNameMap, factory );
|
||||
|
@ -44,6 +44,7 @@
|
||||
import org.hibernate.StaleObjectStateException;
|
||||
import org.hibernate.StaleStateException;
|
||||
import org.hibernate.boot.Metadata;
|
||||
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.boot.spi.SessionFactoryOptions;
|
||||
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
|
||||
@ -765,9 +766,14 @@ public AbstractEntityPersister(
|
||||
propertyDefinedOnSubclass = toBooleanArray( definedBySubclass );
|
||||
|
||||
// Handle any filters applied to the class level
|
||||
filterHelper = isNotEmpty( persistentClass.getFilters() )
|
||||
? new FilterHelper( persistentClass.getFilters(), getEntityNameByTableNameMap( persistentClass ), factory )
|
||||
: null;
|
||||
filterHelper = isNotEmpty( persistentClass.getFilters() ) ? new FilterHelper(
|
||||
persistentClass.getFilters(),
|
||||
getEntityNameByTableNameMap(
|
||||
persistentClass,
|
||||
factory.getSqlStringGenerationContext()
|
||||
),
|
||||
factory
|
||||
) : null;
|
||||
|
||||
useReferenceCacheEntries = shouldUseReferenceCacheEntries( creationContext.getSessionFactoryOptions() );
|
||||
cacheEntryHelper = buildCacheEntryHelper( creationContext.getSessionFactoryOptions() );
|
||||
@ -826,20 +832,22 @@ private SingleIdEntityLoader<?> createSingleIdEntityLoader(LoadQueryInfluencers
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, String> getEntityNameByTableNameMap(PersistentClass persistentClass) {
|
||||
public static Map<String, String> getEntityNameByTableNameMap(
|
||||
PersistentClass persistentClass,
|
||||
SqlStringGenerationContext stringGenerationContext) {
|
||||
final Map<String, String> entityNameByTableNameMap = new HashMap<>();
|
||||
PersistentClass superType = persistentClass.getSuperPersistentClass();
|
||||
while ( superType != null ) {
|
||||
entityNameByTableNameMap.put( superType.getTable().getName(), superType.getEntityName() );
|
||||
entityNameByTableNameMap.put( superType.getTable().getQualifiedName( stringGenerationContext ), superType.getEntityName() );
|
||||
for ( Join join : superType.getJoins() ) {
|
||||
entityNameByTableNameMap.put( join.getTable().getName(), superType.getEntityName() );
|
||||
entityNameByTableNameMap.put( join.getTable().getQualifiedName( stringGenerationContext ), superType.getEntityName() );
|
||||
}
|
||||
superType = superType.getSuperPersistentClass();
|
||||
}
|
||||
for ( PersistentClass subclass : persistentClass.getSubclassClosure() ) {
|
||||
entityNameByTableNameMap.put( subclass.getTable().getName(), subclass.getEntityName() );
|
||||
entityNameByTableNameMap.put( subclass.getTable().getQualifiedName( stringGenerationContext ), subclass.getEntityName() );
|
||||
for ( Join join : subclass.getJoins() ) {
|
||||
entityNameByTableNameMap.put( join.getTable().getName(), subclass.getEntityName() );
|
||||
entityNameByTableNameMap.put( join.getTable().getQualifiedName( stringGenerationContext ), subclass.getEntityName() );
|
||||
}
|
||||
}
|
||||
return entityNameByTableNameMap;
|
||||
|
Loading…
x
Reference in New Issue
Block a user