HHH-13214 Delete re-firing SQL from previous calls

This commit is contained in:
lining 2020-04-17 03:39:31 +08:00 committed by Sanne Grinovero
parent 0614bfe3b8
commit 0b71131136
2 changed files with 11 additions and 2 deletions

View File

@ -8,6 +8,7 @@ package org.hibernate.hql.spi.id.inline;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Collections;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -32,7 +33,7 @@ public abstract class AbstractInlineIdsDeleteHandlerImpl
extends AbstractInlineIdsBulkIdHandler
implements MultiTableBulkIdStrategy.DeleteHandler {
private final List<String> deletes = new ArrayList<>();
private List<String> deletes;
public AbstractInlineIdsDeleteHandlerImpl(
SessionFactoryImplementor factory,
@ -42,6 +43,9 @@ public abstract class AbstractInlineIdsDeleteHandlerImpl
@Override
public String[] getSqlStatements() {
if ( deletes.isEmpty() ) {
return new String[0];
}
return deletes.toArray( new String[deletes.size()] );
}
@ -51,6 +55,7 @@ public abstract class AbstractInlineIdsDeleteHandlerImpl
QueryParameters queryParameters) {
IdsClauseBuilder values = prepareInlineStatement( session, queryParameters );
deletes = new ArrayList<>();
if ( !values.getIds().isEmpty() ) {
final String idSubselect = values.toStatement();

View File

@ -35,7 +35,7 @@ public abstract class AbstractInlineIdsUpdateHandlerImpl
extends AbstractInlineIdsBulkIdHandler
implements MultiTableBulkIdStrategy.UpdateHandler {
private final Map<Integer, String> updates = new LinkedHashMap<>();
private Map<Integer, String> updates;
private ParameterSpecification[][] assignmentParameterSpecifications;
@ -47,6 +47,9 @@ public abstract class AbstractInlineIdsUpdateHandlerImpl
@Override
public String[] getSqlStatements() {
if ( updates == null ) {
return new String[0];
}
return updates.values().toArray( new String[updates.values().size()] );
}
@ -56,6 +59,7 @@ public abstract class AbstractInlineIdsUpdateHandlerImpl
QueryParameters queryParameters) {
IdsClauseBuilder values = prepareInlineStatement( session, queryParameters );
updates = new LinkedHashMap<>();
if ( !values.getIds().isEmpty() ) {