initial work on joined inheritance
This commit is contained in:
parent
5cdf6d4b2b
commit
704ba4f85f
|
@ -29,7 +29,6 @@ import java.util.SortedSet;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
@ -181,8 +180,6 @@ import org.hibernate.sql.ast.spi.SqlAliasStemHelper;
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
||||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||||
import org.hibernate.sql.ast.tree.expression.QueryLiteral;
|
|
||||||
import org.hibernate.sql.ast.tree.from.StandardTableGroup;
|
|
||||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||||
import org.hibernate.sql.ast.tree.from.TableGroupBuilder;
|
import org.hibernate.sql.ast.tree.from.TableGroupBuilder;
|
||||||
import org.hibernate.sql.ast.tree.from.TableReference;
|
import org.hibernate.sql.ast.tree.from.TableReference;
|
||||||
|
@ -6098,7 +6095,7 @@ public abstract class AbstractEntityPersister
|
||||||
|
|
||||||
private SortedMap<String, AttributeMapping> declaredAttributeMappings = new TreeMap<>();
|
private SortedMap<String, AttributeMapping> declaredAttributeMappings = new TreeMap<>();
|
||||||
private List<AttributeMapping> attributeMappings;
|
private List<AttributeMapping> attributeMappings;
|
||||||
private List<Fetchable> staticFetchableList;
|
protected List<Fetchable> staticFetchableList;
|
||||||
|
|
||||||
protected ReflectionOptimizer.AccessOptimizer accessOptimizer;
|
protected ReflectionOptimizer.AccessOptimizer accessOptimizer;
|
||||||
|
|
||||||
|
@ -6118,7 +6115,6 @@ public abstract class AbstractEntityPersister
|
||||||
|
|
||||||
this.identifierMapping = superMappingType.getIdentifierMapping();
|
this.identifierMapping = superMappingType.getIdentifierMapping();
|
||||||
this.versionMapping = superMappingType.getVersionMapping();
|
this.versionMapping = superMappingType.getVersionMapping();
|
||||||
this.discriminatorMapping = superMappingType.getDiscriminatorMapping();
|
|
||||||
this.naturalIdMapping = superMappingType.getNaturalIdMapping();
|
this.naturalIdMapping = superMappingType.getNaturalIdMapping();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -6553,7 +6549,7 @@ public abstract class AbstractEntityPersister
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Fetchable> getStaticFetchableList() {
|
protected List<Fetchable> getStaticFetchableList() {
|
||||||
if ( staticFetchableList == null ) {
|
if ( staticFetchableList == null ) {
|
||||||
staticFetchableList = new ArrayList<>( attributeMappings.size() );
|
staticFetchableList = new ArrayList<>( attributeMappings.size() );
|
||||||
visitAttributeMappings( attributeMapping -> staticFetchableList.add( (Fetchable) attributeMapping ) );
|
visitAttributeMappings( attributeMapping -> staticFetchableList.add( (Fetchable) attributeMapping ) );
|
||||||
|
|
|
@ -9,7 +9,6 @@ package org.hibernate.persister.entity;
|
||||||
import org.hibernate.AssertionFailure;
|
import org.hibernate.AssertionFailure;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.NotYetImplementedFor6Exception;
|
|
||||||
import org.hibernate.QueryException;
|
import org.hibernate.QueryException;
|
||||||
import org.hibernate.boot.model.relational.Database;
|
import org.hibernate.boot.model.relational.Database;
|
||||||
import org.hibernate.cache.spi.access.EntityDataAccess;
|
import org.hibernate.cache.spi.access.EntityDataAccess;
|
||||||
|
@ -35,14 +34,15 @@ import org.hibernate.mapping.Subclass;
|
||||||
import org.hibernate.mapping.Table;
|
import org.hibernate.mapping.Table;
|
||||||
import org.hibernate.mapping.Value;
|
import org.hibernate.mapping.Value;
|
||||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||||
|
import org.hibernate.query.sqm.sql.SqlExpressionResolver;
|
||||||
import org.hibernate.sql.CaseFragment;
|
import org.hibernate.sql.CaseFragment;
|
||||||
import org.hibernate.sql.InFragment;
|
import org.hibernate.sql.InFragment;
|
||||||
import org.hibernate.sql.Insert;
|
import org.hibernate.sql.Insert;
|
||||||
import org.hibernate.sql.SelectFragment;
|
import org.hibernate.sql.SelectFragment;
|
||||||
|
import org.hibernate.sql.results.spi.Fetchable;
|
||||||
import org.hibernate.type.DiscriminatorType;
|
import org.hibernate.type.DiscriminatorType;
|
||||||
import org.hibernate.type.StandardBasicTypes;
|
import org.hibernate.type.StandardBasicTypes;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -130,6 +131,10 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
private final boolean[] isNullableTable;
|
private final boolean[] isNullableTable;
|
||||||
private final boolean[] isInverseTable;
|
private final boolean[] isInverseTable;
|
||||||
|
|
||||||
|
// private final String tableName;
|
||||||
|
//
|
||||||
|
// private final String superClassTableName;
|
||||||
|
|
||||||
//INITIALIZATION:
|
//INITIALIZATION:
|
||||||
|
|
||||||
public JoinedSubclassEntityPersister(
|
public JoinedSubclassEntityPersister(
|
||||||
|
@ -207,6 +212,16 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
throw new MappingException( "optimistic-lock=all|dirty not supported for joined-subclass mappings [" + getEntityName() + "]" );
|
throw new MappingException( "optimistic-lock=all|dirty not supported for joined-subclass mappings [" + getEntityName() + "]" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// final PersistentClass superclass = persistentClass.getSuperclass();
|
||||||
|
// if ( superclass != null ) {
|
||||||
|
// superClassTableName = determineTableName( superclass.getTable(), jdbcEnvironment );
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// superClassTableName = null;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// tableName = determineTableName( persistentClass.getTable(), jdbcEnvironment );
|
||||||
|
|
||||||
//MULTITABLES
|
//MULTITABLES
|
||||||
|
|
||||||
final int idColumnSpan = getIdentifierColumnSpan();
|
final int idColumnSpan = getIdentifierColumnSpan();
|
||||||
|
@ -1073,10 +1088,6 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
return constraintOrderedKeyColumnNames;
|
return constraintOrderedKeyColumnNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRootTableName() {
|
|
||||||
return naturalOrderTableNames[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRootTableAlias(String drivingAlias) {
|
public String getRootTableAlias(String drivingAlias) {
|
||||||
return generateTableAlias( drivingAlias, getTableId( getRootTableName(), tableNames ) );
|
return generateTableAlias( drivingAlias, getTableId( getRootTableName(), tableNames ) );
|
||||||
}
|
}
|
||||||
|
@ -1117,6 +1128,23 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
throw new HibernateException( "Could not locate table which owns column [" + columnName + "] referenced in order-by mapping" );
|
throw new HibernateException( "Could not locate table which owns column [" + columnName + "] referenced in order-by mapping" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void buildDiscriminatorMapping() {
|
||||||
|
if ( hasSubclasses() ) {
|
||||||
|
super.buildDiscriminatorMapping();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Fetchable> getStaticFetchableList() {
|
||||||
|
if ( staticFetchableList == null ) {
|
||||||
|
staticFetchableList = new ArrayList<>( getAttributeMappings().size() );
|
||||||
|
visitAttributeMappings( attributeMapping -> staticFetchableList.add( (Fetchable) attributeMapping ) );
|
||||||
|
|
||||||
|
}
|
||||||
|
return staticFetchableList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FilterAliasGenerator getFilterAliasGenerator(String rootAlias) {
|
public FilterAliasGenerator getFilterAliasGenerator(String rootAlias) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.util.Collections;
|
||||||
import java.util.IdentityHashMap;
|
import java.util.IdentityHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
|
|
@ -38,17 +38,25 @@ public abstract class AbstractColumnReferenceQualifier implements ColumnReferenc
|
||||||
public TableReference resolveTableReference(String tableExpression) {
|
public TableReference resolveTableReference(String tableExpression) {
|
||||||
assert tableExpression != null;
|
assert tableExpression != null;
|
||||||
|
|
||||||
|
final TableReference tableReference = resolveTableReferenceInternal( tableExpression );
|
||||||
|
if ( tableReference == null ) {
|
||||||
|
throw new IllegalStateException( "Could not resolve binding for table `" + tableExpression + "`" );
|
||||||
|
}
|
||||||
|
|
||||||
|
return tableReference;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TableReference resolveTableReferenceInternal(String tableExpression) {
|
||||||
if ( getPrimaryTableReference().getTableExpression().equals( tableExpression ) ) {
|
if ( getPrimaryTableReference().getTableExpression().equals( tableExpression ) ) {
|
||||||
return getPrimaryTableReference();
|
return getPrimaryTableReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( TableReferenceJoin tableJoin : getTableReferenceJoins() ) {
|
for ( TableReferenceJoin tableJoin : getTableReferenceJoins() ) {
|
||||||
if ( tableJoin.getJoinedTableReference().getTableExpression() == tableExpression ) {
|
if ( tableJoin.getJoinedTableReference().getTableExpression().equals( tableExpression ) ) {
|
||||||
return tableJoin.getJoinedTableReference();
|
return tableJoin.getJoinedTableReference();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
throw new IllegalStateException( "Could not resolve binding for table `" + tableExpression + "`" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,4 +57,17 @@ public class StandardTableGroup extends AbstractTableGroup {
|
||||||
public List<TableReferenceJoin> getTableReferenceJoins() {
|
public List<TableReferenceJoin> getTableReferenceJoins() {
|
||||||
return tableJoins;
|
return tableJoins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableReference resolveTableReferenceInternal(String tableExpression) {
|
||||||
|
TableReference tableReference = super.resolveTableReferenceInternal( tableExpression );
|
||||||
|
if ( tableReference == null ) {
|
||||||
|
for ( TableReferenceJoin tableJoin : tableJoins ) {
|
||||||
|
if ( tableJoin.getJoinedTableReference().getTableExpression().equals( tableExpression ) ) {
|
||||||
|
tableReference = tableJoin.getJoinedTableReference();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tableReference;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue