private void doRemovePropertyMetadata(int tableIndex,
int propertyIndex,
Object[] oldColumnValue) {
String[] propertyColumnNames = persister.getPropertyColumnNames( propertyIndex );
String[] rowKeyColumnNames = buildRowKeyColumnNamesForStarToOne( persister, propertyColumnNames );
PropertyMetadataProvider metadataProvider = new PropertyMetadataProvider()
.gridDialect(gridDialect)
.keyColumnNames( propertyColumnNames )
.keyColumnValues( oldColumnValue )
.session( session )
//does not set .collectionPersister as it does not make sense here for a ToOne or a unique key
.tableName( persister.getTableName( tableIndex ) )
.propertyType( persister.getPropertyTypes()[propertyIndex] )
.rowKeyColumnNames( rowKeyColumnNames );
//add fk column value in TupleKey
Tuple tupleKey = new Tuple( EmptyTupleSnapshot.SINGLETON );
for (int index = 0 ; index < propertyColumnNames.length ; index++) {
tupleKey.put( propertyColumnNames[index], oldColumnValue[index] );
}
//add id value in TupleKey
gridIdentifierType.nullSafeSet( tupleKey, id, persister.getIdentifierColumnNames(), session );
Association propertyValues = metadataProvider.getCollectionMetadata();
if ( propertyValues != null ) {
//Map's equals operation delegates to all it's key and value, should be fine for now
//this is a StarToOne case ie the FK is on the owning entity
final RowKey matchingTuple = new RowKeyBuilder()
.tableName( persister.getTableName() )
.addColumns( buildRowKeyColumnNamesForStarToOne( persister, propertyColumnNames ) )
.values( tupleKey )
.build();
//TODO what should we do if that's null?
metadataProvider.getCollectionMetadata().remove( matchingTuple );
metadataProvider.flushToCache();
}
}