HHH-17914 - correct the NPE protection in AbstractCollectionPersister.logStaticSQL()

checking if `getRowMutationOperations().hasInsertRow()` (e.g.) is not enough to avoid a possible NPE at
`getRowMutationOperations().getInsertRowOperation().getSqlString()` since `getInsertRowOperation()` can still return null

Signed-off-by: Jan Schatteman <jschatte@redhat.com>
This commit is contained in:
Jan Schatteman 2024-07-11 00:07:33 +02:00 committed by Christian Beikov
parent 8ab4b177be
commit b48d0cf0f3
1 changed files with 12 additions and 15 deletions

View File

@ -718,26 +718,23 @@ public abstract class AbstractCollectionPersister
MODEL_MUTATION_LOGGER.debugf( "Static SQL for collection: %s", getRole() );
if ( getRowMutationOperations().hasInsertRow() ) {
final String insertRowSql = getRowMutationOperations().getInsertRowOperation().getSqlString();
final JdbcMutationOperation insertRowOperation = getRowMutationOperations().getInsertRowOperation();
final String insertRowSql = insertRowOperation != null ? insertRowOperation.getSqlString() : null;
if ( insertRowSql != null ) {
MODEL_MUTATION_LOGGER.debugf( " Row insert: %s", insertRowSql );
}
}
if ( getRowMutationOperations().hasUpdateRow() ) {
final String updateRowSql = getRowMutationOperations().getUpdateRowOperation().getSqlString();
final JdbcMutationOperation updateRowOperation = getRowMutationOperations().getUpdateRowOperation();
final String updateRowSql = updateRowOperation != null ? updateRowOperation.getSqlString() : null;
if ( updateRowSql != null ) {
MODEL_MUTATION_LOGGER.debugf( " Row update: %s", updateRowSql );
}
}
if ( getRowMutationOperations().hasDeleteRow() ) {
final String deleteRowSql = getRowMutationOperations().getDeleteRowOperation().getSqlString();
final JdbcMutationOperation deleteRowOperation = getRowMutationOperations().getDeleteRowOperation();
final String deleteRowSql = deleteRowOperation != null ? deleteRowOperation.getSqlString() : null;
if ( deleteRowSql != null ) {
MODEL_MUTATION_LOGGER.debugf( " Row delete: %s", deleteRowSql );
}
}
final String deleteAllSql = getRemoveCoordinator().getSqlString();
if ( deleteAllSql != null ) {