HHH-16346 Relax scopes for TableBased*Handler
So that Hibernate Reactive can create a custom LocalTemporaryTableStrategy
This commit is contained in:
parent
3598ee25a9
commit
eeccc9c99d
|
@ -64,7 +64,7 @@ public class TableBasedDeleteHandler
|
||||||
return resolveDelegate( executionContext ).execute( executionContext );
|
return resolveDelegate( executionContext ).execute( executionContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExecutionDelegate resolveDelegate(DomainQueryExecutionContext executionContext) {
|
protected ExecutionDelegate resolveDelegate(DomainQueryExecutionContext executionContext) {
|
||||||
return new RestrictedDeleteExecutionDelegate(
|
return new RestrictedDeleteExecutionDelegate(
|
||||||
getEntityDescriptor(),
|
getEntityDescriptor(),
|
||||||
idTable,
|
idTable,
|
||||||
|
@ -79,6 +79,23 @@ public class TableBasedDeleteHandler
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Getters for Hibernat Reactive
|
||||||
|
protected TemporaryTable getIdTable() {
|
||||||
|
return idTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AfterUseAction getAfterUseAction() {
|
||||||
|
return afterUseAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Function<SharedSessionContractImplementor, String> getSessionUidAccess() {
|
||||||
|
return sessionUidAccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DomainParameterXref getDomainParameterXref() {
|
||||||
|
return domainParameterXref;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SqmDeleteStatement<?> getSqmDeleteOrUpdateStatement() {
|
public SqmDeleteStatement<?> getSqmDeleteOrUpdateStatement() {
|
||||||
return (SqmDeleteStatement<?>) super.getSqmDeleteOrUpdateStatement();
|
return (SqmDeleteStatement<?>) super.getSqmDeleteOrUpdateStatement();
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class TableBasedInsertHandler implements InsertHandler {
|
||||||
private final DomainParameterXref domainParameterXref;
|
private final DomainParameterXref domainParameterXref;
|
||||||
private final JdbcParameter sessionUidParameter;
|
private final JdbcParameter sessionUidParameter;
|
||||||
|
|
||||||
TableBasedInsertHandler(
|
public TableBasedInsertHandler(
|
||||||
SqmInsertStatement<?> sqmInsert,
|
SqmInsertStatement<?> sqmInsert,
|
||||||
DomainParameterXref domainParameterXref,
|
DomainParameterXref domainParameterXref,
|
||||||
TemporaryTable entityTable,
|
TemporaryTable entityTable,
|
||||||
|
@ -116,7 +116,7 @@ public class TableBasedInsertHandler implements InsertHandler {
|
||||||
return resolveDelegate( executionContext ).execute( executionContextAdapter );
|
return resolveDelegate( executionContext ).execute( executionContextAdapter );
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExecutionDelegate resolveDelegate(DomainQueryExecutionContext executionContext) {
|
protected ExecutionDelegate resolveDelegate(DomainQueryExecutionContext executionContext) {
|
||||||
final EntityPersister entityDescriptor = sessionFactory.getRuntimeMetamodels()
|
final EntityPersister entityDescriptor = sessionFactory.getRuntimeMetamodels()
|
||||||
.getMappingMetamodel()
|
.getMappingMetamodel()
|
||||||
.getEntityDescriptor( getSqmInsertStatement().getTarget().getEntityName() );
|
.getEntityDescriptor( getSqmInsertStatement().getTarget().getEntityName() );
|
||||||
|
@ -319,7 +319,7 @@ public class TableBasedInsertHandler implements InsertHandler {
|
||||||
collectTableReference( insertingTableGroup.getTableReferenceJoins().get( i ), tableReferenceByAlias::put );
|
collectTableReference( insertingTableGroup.getTableReferenceJoins().get( i ), tableReferenceByAlias::put );
|
||||||
}
|
}
|
||||||
|
|
||||||
return new InsertExecutionDelegate(
|
return buildExecutionDelegate(
|
||||||
sqmInsertStatement,
|
sqmInsertStatement,
|
||||||
converterDelegate,
|
converterDelegate,
|
||||||
entityTable,
|
entityTable,
|
||||||
|
@ -337,6 +337,40 @@ public class TableBasedInsertHandler implements InsertHandler {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For Hibernate Reactive
|
||||||
|
protected ExecutionDelegate buildExecutionDelegate(
|
||||||
|
SqmInsertStatement<?> sqmInsert,
|
||||||
|
MultiTableSqmMutationConverter sqmConverter,
|
||||||
|
TemporaryTable entityTable,
|
||||||
|
AfterUseAction afterUseAction,
|
||||||
|
Function<SharedSessionContractImplementor, String> sessionUidAccess,
|
||||||
|
DomainParameterXref domainParameterXref,
|
||||||
|
TableGroup insertingTableGroup,
|
||||||
|
Map<String, TableReference> tableReferenceByAlias,
|
||||||
|
List<Assignment> assignments,
|
||||||
|
InsertSelectStatement insertStatement,
|
||||||
|
Map<SqmParameter<?>, List<List<JdbcParameter>>> parameterResolutions,
|
||||||
|
JdbcParameter sessionUidParameter,
|
||||||
|
Map<SqmParameter<?>, MappingModelExpressible<?>> paramTypeResolutions,
|
||||||
|
DomainQueryExecutionContext executionContext) {
|
||||||
|
return new InsertExecutionDelegate(
|
||||||
|
sqmInsertStatement,
|
||||||
|
sqmConverter,
|
||||||
|
entityTable,
|
||||||
|
afterUseAction,
|
||||||
|
sessionUidAccess,
|
||||||
|
domainParameterXref,
|
||||||
|
insertingTableGroup,
|
||||||
|
tableReferenceByAlias,
|
||||||
|
assignments,
|
||||||
|
insertStatement,
|
||||||
|
parameterResolutions,
|
||||||
|
sessionUidParameter,
|
||||||
|
paramTypeResolutions,
|
||||||
|
executionContext
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void collectTableReference(
|
private void collectTableReference(
|
||||||
TableReference tableReference,
|
TableReference tableReference,
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class TableBasedUpdateHandler
|
||||||
|
|
||||||
private final EntityPersister entityDescriptor;
|
private final EntityPersister entityDescriptor;
|
||||||
|
|
||||||
TableBasedUpdateHandler(
|
public TableBasedUpdateHandler(
|
||||||
SqmUpdateStatement<?> sqmUpdate,
|
SqmUpdateStatement<?> sqmUpdate,
|
||||||
DomainParameterXref domainParameterXref,
|
DomainParameterXref domainParameterXref,
|
||||||
TemporaryTable idTable,
|
TemporaryTable idTable,
|
||||||
|
@ -102,7 +102,7 @@ public class TableBasedUpdateHandler
|
||||||
return resolveDelegate( executionContext ).execute( executionContextAdapter );
|
return resolveDelegate( executionContext ).execute( executionContextAdapter );
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExecutionDelegate resolveDelegate(DomainQueryExecutionContext executionContext) {
|
protected ExecutionDelegate resolveDelegate(DomainQueryExecutionContext executionContext) {
|
||||||
final SessionFactoryImplementor sessionFactory = getSessionFactory();
|
final SessionFactoryImplementor sessionFactory = getSessionFactory();
|
||||||
final MappingMetamodel domainModel = sessionFactory.getRuntimeMetamodels().getMappingMetamodel();
|
final MappingMetamodel domainModel = sessionFactory.getRuntimeMetamodels().getMappingMetamodel();
|
||||||
final EntityPersister entityDescriptor = domainModel.getEntityDescriptor( getSqmDeleteOrUpdateStatement().getTarget().getEntityName() );
|
final EntityPersister entityDescriptor = domainModel.getEntityDescriptor( getSqmDeleteOrUpdateStatement().getTarget().getEntityName() );
|
||||||
|
@ -207,7 +207,7 @@ public class TableBasedUpdateHandler
|
||||||
collectTableReference( updatingTableGroup.getTableReferenceJoins().get( i ), tableReferenceByAlias::put );
|
collectTableReference( updatingTableGroup.getTableReferenceJoins().get( i ), tableReferenceByAlias::put );
|
||||||
}
|
}
|
||||||
|
|
||||||
return new UpdateExecutionDelegate(
|
return buildExecutionDelegate(
|
||||||
converterDelegate,
|
converterDelegate,
|
||||||
idTable,
|
idTable,
|
||||||
afterUseAction,
|
afterUseAction,
|
||||||
|
@ -223,18 +223,44 @@ public class TableBasedUpdateHandler
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected UpdateExecutionDelegate buildExecutionDelegate(
|
||||||
|
MultiTableSqmMutationConverter sqmConverter,
|
||||||
|
TemporaryTable idTable,
|
||||||
|
AfterUseAction afterUseAction,
|
||||||
|
Function<SharedSessionContractImplementor, String> sessionUidAccess,
|
||||||
|
DomainParameterXref domainParameterXref,
|
||||||
|
TableGroup updatingTableGroup,
|
||||||
|
Map<String, TableReference> tableReferenceByAlias,
|
||||||
|
List<Assignment> assignments,
|
||||||
|
Predicate suppliedPredicate,
|
||||||
|
Map<SqmParameter<?>, List<List<JdbcParameter>>> parameterResolutions,
|
||||||
|
Map<SqmParameter<?>, MappingModelExpressible<?>> paramTypeResolutions,
|
||||||
|
DomainQueryExecutionContext executionContext) {
|
||||||
|
return new UpdateExecutionDelegate(
|
||||||
|
sqmConverter,
|
||||||
|
idTable,
|
||||||
|
afterUseAction,
|
||||||
|
sessionUidAccess,
|
||||||
|
domainParameterXref,
|
||||||
|
updatingTableGroup,
|
||||||
|
tableReferenceByAlias,
|
||||||
|
assignments,
|
||||||
|
suppliedPredicate,
|
||||||
|
parameterResolutions,
|
||||||
|
paramTypeResolutions,
|
||||||
|
executionContext
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private void collectTableReference(
|
protected void collectTableReference(
|
||||||
TableReference tableReference,
|
TableReference tableReference,
|
||||||
BiConsumer<String, TableReference> consumer) {
|
BiConsumer<String, TableReference> consumer) {
|
||||||
consumer.accept( tableReference.getIdentificationVariable(), tableReference );
|
consumer.accept( tableReference.getIdentificationVariable(), tableReference );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collectTableReference(
|
protected void collectTableReference(
|
||||||
TableReferenceJoin tableReferenceJoin,
|
TableReferenceJoin tableReferenceJoin,
|
||||||
BiConsumer<String, TableReference> consumer) {
|
BiConsumer<String, TableReference> consumer) {
|
||||||
collectTableReference( tableReferenceJoin.getJoinedTableReference(), consumer );
|
collectTableReference( tableReferenceJoin.getJoinedTableReference(), consumer );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,7 +205,7 @@ public class UpdateExecutionDelegate implements TableBasedUpdateHandler.Executio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TableReference resolveTableReference(
|
protected TableReference resolveTableReference(
|
||||||
ColumnReference columnReference,
|
ColumnReference columnReference,
|
||||||
Map<String, TableReference> tableReferenceByAlias) {
|
Map<String, TableReference> tableReferenceByAlias) {
|
||||||
final TableReference tableReferenceByQualifier = tableReferenceByAlias.get( columnReference.getQualifier() );
|
final TableReference tableReferenceByQualifier = tableReferenceByAlias.get( columnReference.getQualifier() );
|
||||||
|
@ -216,7 +216,7 @@ public class UpdateExecutionDelegate implements TableBasedUpdateHandler.Executio
|
||||||
throw new SemanticException( "Assignment referred to column of a joined association: " + columnReference );
|
throw new SemanticException( "Assignment referred to column of a joined association: " + columnReference );
|
||||||
}
|
}
|
||||||
|
|
||||||
private NamedTableReference resolveUnionTableReference(
|
protected NamedTableReference resolveUnionTableReference(
|
||||||
TableReference tableReference,
|
TableReference tableReference,
|
||||||
String tableExpression) {
|
String tableExpression) {
|
||||||
if ( tableReference instanceof UnionTableReference ) {
|
if ( tableReference instanceof UnionTableReference ) {
|
||||||
|
@ -284,7 +284,7 @@ public class UpdateExecutionDelegate implements TableBasedUpdateHandler.Executio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isTableOptional(String tableExpression) {
|
protected boolean isTableOptional(String tableExpression) {
|
||||||
final AbstractEntityPersister entityPersister = (AbstractEntityPersister) entityDescriptor.getEntityPersister();
|
final AbstractEntityPersister entityPersister = (AbstractEntityPersister) entityDescriptor.getEntityPersister();
|
||||||
for ( int i = 0; i < entityPersister.getTableSpan(); i++ ) {
|
for ( int i = 0; i < entityPersister.getTableSpan(); i++ ) {
|
||||||
if ( tableExpression.equals( entityPersister.getTableName( i ) )
|
if ( tableExpression.equals( entityPersister.getTableName( i ) )
|
||||||
|
@ -371,7 +371,7 @@ public class UpdateExecutionDelegate implements TableBasedUpdateHandler.Executio
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private QuerySpec createExistsSubQuerySpec(String targetTableExpression, Supplier<Consumer<SelectableConsumer>> tableKeyColumnVisitationSupplier, QuerySpec idTableSubQuery) {
|
protected QuerySpec createExistsSubQuerySpec(String targetTableExpression, Supplier<Consumer<SelectableConsumer>> tableKeyColumnVisitationSupplier, QuerySpec idTableSubQuery) {
|
||||||
final NamedTableReference existsTableReference = new NamedTableReference(
|
final NamedTableReference existsTableReference = new NamedTableReference(
|
||||||
targetTableExpression,
|
targetTableExpression,
|
||||||
"dml_"
|
"dml_"
|
||||||
|
@ -411,7 +411,7 @@ public class UpdateExecutionDelegate implements TableBasedUpdateHandler.Executio
|
||||||
return existsSubQuerySpec;
|
return existsSubQuerySpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static QuerySpec makeInsertSourceSelectQuerySpec(QuerySpec idTableSubQuery) {
|
protected static QuerySpec makeInsertSourceSelectQuerySpec(QuerySpec idTableSubQuery) {
|
||||||
final QuerySpec idTableQuerySpec = new QuerySpec( true );
|
final QuerySpec idTableQuerySpec = new QuerySpec( true );
|
||||||
for ( TableGroup root : idTableSubQuery.getFromClause().getRoots() ) {
|
for ( TableGroup root : idTableSubQuery.getFromClause().getRoots() ) {
|
||||||
idTableQuerySpec.getFromClause().addRoot( root );
|
idTableQuerySpec.getFromClause().addRoot( root );
|
||||||
|
@ -448,7 +448,7 @@ public class UpdateExecutionDelegate implements TableBasedUpdateHandler.Executio
|
||||||
return updateCount;
|
return updateCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Expression resolveMutatingTableKeyExpression(String tableExpression, Supplier<Consumer<SelectableConsumer>> tableKeyColumnVisitationSupplier) {
|
protected Expression resolveMutatingTableKeyExpression(String tableExpression, Supplier<Consumer<SelectableConsumer>> tableKeyColumnVisitationSupplier) {
|
||||||
final TableKeyExpressionCollector keyColumnCollector = new TableKeyExpressionCollector( entityDescriptor );
|
final TableKeyExpressionCollector keyColumnCollector = new TableKeyExpressionCollector( entityDescriptor );
|
||||||
|
|
||||||
tableKeyColumnVisitationSupplier.get().accept(
|
tableKeyColumnVisitationSupplier.get().accept(
|
||||||
|
@ -461,7 +461,7 @@ public class UpdateExecutionDelegate implements TableBasedUpdateHandler.Executio
|
||||||
return keyColumnCollector.buildKeyExpression();
|
return keyColumnCollector.buildKeyExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Expression asExpression(SelectClause selectClause) {
|
protected Expression asExpression(SelectClause selectClause) {
|
||||||
final List<SqlSelection> sqlSelections = selectClause.getSqlSelections();
|
final List<SqlSelection> sqlSelections = selectClause.getSqlSelections();
|
||||||
if ( sqlSelections.size() == 1 ) {
|
if ( sqlSelections.size() == 1 ) {
|
||||||
return sqlSelections.get( 0 ).getExpression();
|
return sqlSelections.get( 0 ).getExpression();
|
||||||
|
@ -472,4 +472,46 @@ public class UpdateExecutionDelegate implements TableBasedUpdateHandler.Executio
|
||||||
}
|
}
|
||||||
return new SqlTuple( expressions, null );
|
return new SqlTuple( expressions, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FOr Hibernate Reactive
|
||||||
|
|
||||||
|
protected TemporaryTable getIdTable() {
|
||||||
|
return idTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Predicate getSuppliedPredicate() {
|
||||||
|
return suppliedPredicate;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MultiTableSqmMutationConverter getSqmConverter() {
|
||||||
|
return sqmConverter;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Function<SharedSessionContractImplementor, String> getSessionUidAccess() {
|
||||||
|
return sessionUidAccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected JdbcParameterBindings getJdbcParameterBindings() {
|
||||||
|
return jdbcParameterBindings;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected EntityMappingType getEntityDescriptor() {
|
||||||
|
return entityDescriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AfterUseAction getAfterUseAction() {
|
||||||
|
return afterUseAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TableGroup getUpdatingTableGroup() {
|
||||||
|
return updatingTableGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Map<TableReference, List<Assignment>> getAssignmentsByTable() {
|
||||||
|
return assignmentsByTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SessionFactoryImplementor getSessionFactory() {
|
||||||
|
return sessionFactory;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue