return 0;
}
int count = 0;
int i = 0;
Iterator<?> entries = collection.entries( this );
AssociationPersister associationPersister = getAssociationPersister( collection.getOwner(), key, session );
while ( entries.hasNext() ) {
Object entry = entries.next();
if ( collection.needsUpdating( entry, i, elementType ) ) {
// find the matching element
RowKey assocEntryKey = getTupleKeyForUpdate( key, collection, session, i, entry, associationPersister );
Tuple assocEntryTuple = associationPersister.getAssociation().get( assocEntryKey );
if ( assocEntryTuple == null ) {
throw new AssertionFailure( "Updating a collection tuple that is not present: " + "table {" + getTableName() + "} collectionKey {" + key + "} entry {" + entry + "}" );
}
// update the matching element
// FIXME update the associated entity key data
updateInverseSideOfAssociationNavigation( session, entry, assocEntryTuple, Action.REMOVE, assocEntryKey );
getElementGridType().nullSafeSet(
assocEntryTuple,
collection.getElement( entry ),
getElementColumnNames(),
session
);
// put back entry tuple to actually apply changes to the store
associationPersister.getAssociation().put( assocEntryKey, assocEntryTuple );
updateInverseSideOfAssociationNavigation( session, entry, assocEntryTuple, Action.ADD, assocEntryKey );
count++;
}
i++;
}
// need to put the data back in the cache
associationPersister.flushToDatastore();
return count;
}