Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,17 @@ public void addToBatch(JdbcValueBindings jdbcValueBindings, TableInclusionChecke
if ( inclusionChecker != null
&& !inclusionChecker.include( statementDetails.getMutatingTableDetails() ) ) {
if ( loggerTraceEnabled ) {
MODEL_MUTATION_LOGGER.tracef(
"Skipping addBatch for table: %s (batch position %s)",
MODEL_MUTATION_LOGGER.skippingAddBatchForTable(
statementDetails.getMutatingTableDetails().getTableName(),
batchPosition+1
);
}
}
else {
MODEL_MUTATION_LOGGER.addBatchForTable(
statementDetails.getMutatingTableDetails().getTableName(),
batchPosition+1
);
//noinspection resource
final var statement = statementDetails.resolveStatement();
final String sqlString = statementDetails.getSqlString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,7 @@ protected void performNonBatchedMutation(
final TableMapping tableDetails = statementDetails.getMutatingTableDetails();
if ( inclusionChecker != null && !inclusionChecker.include( tableDetails ) ) {
if ( MODEL_MUTATION_LOGGER.isTraceEnabled() ) {
MODEL_MUTATION_LOGGER.tracef(
"Skipping execution of secondary insert: %s",
tableDetails.getTableName()
);
MODEL_MUTATION_LOGGER.skippingSecondaryInsert( tableDetails.getTableName() );
}
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,31 +724,31 @@ private NamedQueryMemento<?> getNamedQueryMemento(MetadataImplementor bootModel)

protected void logStaticSQL() {
if ( MODEL_MUTATION_LOGGER.isTraceEnabled() ) {
MODEL_MUTATION_LOGGER.tracef( "Static SQL for collection: %s", getRole() );
MODEL_MUTATION_LOGGER.staticSqlForCollection( getRole() );

final var rowMutationOperations = getRowMutationOperations();

final var insertRowOperation = rowMutationOperations.getInsertRowOperation();
final String insertRowSql = insertRowOperation != null ? insertRowOperation.getSqlString() : null;
if ( insertRowSql != null ) {
MODEL_MUTATION_LOGGER.tracef( " Row insert: %s", insertRowSql );
MODEL_MUTATION_LOGGER.collectionRowInsert( insertRowSql );
}

final var updateRowOperation = rowMutationOperations.getUpdateRowOperation();
final String updateRowSql = updateRowOperation != null ? updateRowOperation.getSqlString() : null;
if ( updateRowSql != null ) {
MODEL_MUTATION_LOGGER.tracef( " Row update: %s", updateRowSql );
MODEL_MUTATION_LOGGER.collectionRowUpdate( updateRowSql );
}

final var deleteRowOperation = rowMutationOperations.getDeleteRowOperation();
final String deleteRowSql = deleteRowOperation != null ? deleteRowOperation.getSqlString() : null;
if ( deleteRowSql != null ) {
MODEL_MUTATION_LOGGER.tracef( " Row delete: %s", deleteRowSql );
MODEL_MUTATION_LOGGER.collectionRowDelete( deleteRowSql );
}

final String deleteAllSql = getRemoveCoordinator().getSqlString();
if ( deleteAllSql != null ) {
MODEL_MUTATION_LOGGER.tracef( " One-shot delete: %s", deleteAllSql );
MODEL_MUTATION_LOGGER.collectionOneShotDelete( deleteAllSql );
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ public CollectionMutationTarget getMutationTarget() {

@Override
public void updateRows(Object key, PersistentCollection<?> collection, SharedSessionContractImplementor session) {
MODEL_MUTATION_LOGGER.tracef( "Updating collection rows - %s#%s", mutationTarget.getRolePath(), key );
MODEL_MUTATION_LOGGER.updatingCollectionRows( mutationTarget.getRolePath(), key );

// update all the modified entries
int count = doUpdate( key, collection, session );

MODEL_MUTATION_LOGGER.tracef( "Updated %s collection rows - %s#%s", count, mutationTarget.getRolePath(), key );
MODEL_MUTATION_LOGGER.updatedCollectionRows( count, mutationTarget.getRolePath(), key );
}

protected abstract int doUpdate(Object key, PersistentCollection<?> collection, SharedSessionContractImplementor session);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ public void deleteRows(PersistentCollection<?> collection, Object key, SharedSes
}

if ( MODEL_MUTATION_LOGGER.isTraceEnabled() ) {
MODEL_MUTATION_LOGGER.tracef(
"Deleting removed collection rows - %s : %s",
mutationTarget.getRolePath(),
key
);
MODEL_MUTATION_LOGGER.deletingRemovedCollectionRows( mutationTarget.getRolePath(), key );
}

final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor(
Expand All @@ -80,7 +76,7 @@ public void deleteRows(PersistentCollection<?> collection, Object key, SharedSes

final Iterator<?> deletes = collection.getDeletes( collectionDescriptor, !deleteByIndex );
if ( !deletes.hasNext() ) {
MODEL_MUTATION_LOGGER.trace( "No rows to delete" );
MODEL_MUTATION_LOGGER.noRowsToDelete();
return;
}

Expand All @@ -105,8 +101,7 @@ public void deleteRows(PersistentCollection<?> collection, Object key, SharedSes
deletionCount++;
}

MODEL_MUTATION_LOGGER.tracef( "Done deleting %s collection rows : %s",
deletionCount, mutationTarget.getRolePath() );
MODEL_MUTATION_LOGGER.doneDeletingCollectionRows( deletionCount, mutationTarget.getRolePath() );
}
finally {
mutationExecutor.release();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,15 @@ public CollectionMutationTarget getMutationTarget() {
@Override
public void deleteRows(PersistentCollection<?> collection, Object key, SharedSessionContractImplementor session) {
if ( MODEL_MUTATION_LOGGER.isTraceEnabled() ) {
MODEL_MUTATION_LOGGER.tracef(
"Deleting removed collection rows - %s : %s",
mutationTarget.getRolePath(),
key
);
MODEL_MUTATION_LOGGER.deletingRemovedCollectionRows( mutationTarget.getRolePath(), key );
}

final PluralAttributeMapping pluralAttribute = mutationTarget.getTargetPart();
final CollectionPersister collectionDescriptor = pluralAttribute.getCollectionDescriptor();

final Iterator<?> deletes = collection.getDeletes( collectionDescriptor, !deleteByIndex );
if ( !deletes.hasNext() ) {
MODEL_MUTATION_LOGGER.trace( "No rows to delete" );
MODEL_MUTATION_LOGGER.noRowsToDelete();
return;
}
final MutationExecutor[] executors = new MutationExecutor[subclassEntries.length];
Expand Down Expand Up @@ -108,8 +104,7 @@ public void deleteRows(PersistentCollection<?> collection, Object key, SharedSes
deletionCount++;
}

MODEL_MUTATION_LOGGER.tracef( "Done deleting %s collection rows : %s",
deletionCount, mutationTarget.getRolePath() );
MODEL_MUTATION_LOGGER.doneDeletingCollectionRows( deletionCount, mutationTarget.getRolePath() );
}
finally {
for ( MutationExecutor executor : executors ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@ public void insertRows(
}

if ( MODEL_MUTATION_LOGGER.isTraceEnabled() ) {
MODEL_MUTATION_LOGGER.tracef(
"Inserting collection rows - %s : %s",
mutationTarget.getRolePath(),
id
);
MODEL_MUTATION_LOGGER.insertingNewCollectionRows( mutationTarget.getRolePath(), id );
}

final PluralAttributeMapping pluralAttribute = mutationTarget.getTargetPart();
Expand All @@ -87,11 +83,7 @@ public void insertRows(
final Iterator<?> entries = collection.entries( collectionDescriptor );
collection.preInsert( collectionDescriptor );
if ( !entries.hasNext() ) {
MODEL_MUTATION_LOGGER.tracef(
"No collection rows to insert - %s : %s",
mutationTarget.getRolePath(),
id
);
MODEL_MUTATION_LOGGER.noCollectionRowsToInsert( mutationTarget.getRolePath(), id );
return;
}

Expand All @@ -118,8 +110,7 @@ public void insertRows(
entryCount++;
}

MODEL_MUTATION_LOGGER.tracef( "Done inserting %s collection rows : %s",
entryCount, mutationTarget.getRolePath() );
MODEL_MUTATION_LOGGER.doneInsertingCollectionRows( entryCount, mutationTarget.getRolePath() );

}
finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,8 @@ public void insertRows(
Object id,
EntryFilter entryChecker,
SharedSessionContractImplementor session) {
final boolean loggerTraceEnabled = MODEL_MUTATION_LOGGER.isTraceEnabled();
if ( loggerTraceEnabled ) {
MODEL_MUTATION_LOGGER.tracef(
"Inserting collection rows - %s : %s",
mutationTarget.getRolePath(),
id
);
if ( MODEL_MUTATION_LOGGER.isTraceEnabled() ) {
MODEL_MUTATION_LOGGER.insertingNewCollectionRows( mutationTarget.getRolePath(), id );
}

final PluralAttributeMapping pluralAttribute = mutationTarget.getTargetPart();
Expand All @@ -80,13 +75,7 @@ public void insertRows(
final Iterator<?> entries = collection.entries( collectionDescriptor );
collection.preInsert( collectionDescriptor );
if ( !entries.hasNext() ) {
if ( loggerTraceEnabled ) {
MODEL_MUTATION_LOGGER.tracef(
"No collection rows to insert - %s : %s",
mutationTarget.getRolePath(),
id
);
}
MODEL_MUTATION_LOGGER.noCollectionRowsToInsert( mutationTarget.getRolePath(), id );
return;
}
final MutationExecutor[] executors = new MutationExecutor[subclassEntries.length];
Expand Down Expand Up @@ -125,13 +114,7 @@ public void insertRows(
entryCount++;
}

if ( loggerTraceEnabled ) {
MODEL_MUTATION_LOGGER.tracef(
"Done inserting %s collection rows: %s",
entryCount,
mutationTarget.getRolePath()
);
}
MODEL_MUTATION_LOGGER.doneInsertingCollectionRows( entryCount, mutationTarget.getRolePath() );

}
finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ public String getSqlString() {
@Override
public void deleteAllRows(Object key, SharedSessionContractImplementor session) {
if ( MODEL_MUTATION_LOGGER.isTraceEnabled() ) {
MODEL_MUTATION_LOGGER.tracef(
"Deleting collection - %s : %s",
mutationTarget.getRolePath(),
key
);
MODEL_MUTATION_LOGGER.removingCollection( mutationTarget.getRolePath(), key );
}

if ( operationGroup == null ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ public String getSqlString() {
@Override
public void deleteAllRows(Object key, SharedSessionContractImplementor session) {
if ( MODEL_MUTATION_LOGGER.isTraceEnabled() ) {
MODEL_MUTATION_LOGGER.tracef(
"Deleting collection - %s : %s",
mutationTarget.getRolePath(),
key
);
MODEL_MUTATION_LOGGER.removingCollection( mutationTarget.getRolePath(), key );
}

MutationOperationGroup[] operationGroups = this.operationGroups;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -2429,7 +2428,7 @@ public int[] resolveDirtyAttributeIndexes(
final Object[] previousState,
final String[] attributeNames,
final SessionImplementor session) {
final BitSet mutablePropertiesIndexes = getMutablePropertiesIndexes();
final var mutablePropertiesIndexes = getMutablePropertiesIndexes();
final int estimatedSize =
attributeNames == null
? 0
Expand Down Expand Up @@ -2747,21 +2746,20 @@ public ModelPart getIdentifierDescriptor() {

protected void logStaticSQL() {
if ( MODEL_MUTATION_LOGGER.isTraceEnabled() ) {
MODEL_MUTATION_LOGGER.tracef( "Static SQL for entity: %s", getEntityName() );
MODEL_MUTATION_LOGGER.staticSqlForEntity( getEntityName() );
for ( var entry : lazyLoadPlanByFetchGroup.entrySet() ) {
MODEL_MUTATION_LOGGER.tracef( " Lazy select (%s) : %s",
entry.getKey(), entry.getValue().getJdbcSelect().getSqlString() );
MODEL_MUTATION_LOGGER.lazySelect( String.valueOf(entry.getKey()), entry.getValue().getJdbcSelect().getSqlString() );
}
if ( sqlVersionSelectString != null ) {
MODEL_MUTATION_LOGGER.tracef( " Version select: %s", sqlVersionSelectString );
MODEL_MUTATION_LOGGER.versionSelect( sqlVersionSelectString );
}

{
final var staticInsertGroup = insertCoordinator.getStaticMutationOperationGroup();
if ( staticInsertGroup != null ) {
for ( int i = 0; i < staticInsertGroup.getNumberOfOperations(); i++ ) {
if ( staticInsertGroup.getOperation( i ) instanceof JdbcOperation jdbcOperation ) {
MODEL_MUTATION_LOGGER.tracef( " Insert (%s): %s", i, jdbcOperation.getSqlString() );
MODEL_MUTATION_LOGGER.insertOperationSql( i, jdbcOperation.getSqlString() );
}
}
}
Expand All @@ -2772,7 +2770,7 @@ protected void logStaticSQL() {
if ( staticUpdateGroup != null ) {
for ( int i = 0; i < staticUpdateGroup.getNumberOfOperations(); i++ ) {
if ( staticUpdateGroup.getOperation( i ) instanceof JdbcOperation jdbcOperation ) {
MODEL_MUTATION_LOGGER.tracef( " Update (%s): %s", i, jdbcOperation.getSqlString() );
MODEL_MUTATION_LOGGER.updateOperationSql( i, jdbcOperation.getSqlString() );
}
}
}
Expand All @@ -2783,7 +2781,7 @@ protected void logStaticSQL() {
if ( staticDeleteGroup != null ) {
for ( int i = 0; i < staticDeleteGroup.getNumberOfOperations(); i++ ) {
if ( staticDeleteGroup.getOperation( i ) instanceof JdbcOperation jdbcOperation ) {
MODEL_MUTATION_LOGGER.tracef( " Delete (%s): %s", i, jdbcOperation.getSqlString() );
MODEL_MUTATION_LOGGER.deleteOperationSql( i, jdbcOperation.getSqlString() );
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import static org.hibernate.sql.model.ModelMutationLogging.MODEL_MUTATION_LOGGER;


/**
* Base support for coordinating mutations against an entity
*
Expand Down Expand Up @@ -100,10 +101,7 @@ protected MutationOperationGroup createOperationGroup(ValuesAnalysis valuesAnaly
}
else {
skipped++;
MODEL_MUTATION_LOGGER.tracef(
"Skipping table update - %s",
tableMutation.getTableName()
);
MODEL_MUTATION_LOGGER.skippingUpdate( tableMutation.getTableName() );
}
}
if ( skipped != 0 ) {
Expand Down
Loading