* Creates an association row representing the given entry and adds it to the association managed by the given
* persister.
*/
private RowKeyAndTuple createAndPutAssociationRowForInsert(Serializable key, PersistentCollection collection,
AssociationPersister associationPersister, SessionImplementor session, int i, Object entry) {
RowKeyBuilder rowKeyBuilder = initializeRowKeyBuilder();
Tuple associationRow = new Tuple();
// the collection has a surrogate key (see @CollectionId)
if ( hasIdentifier ) {
final Object identifier = collection.getIdentifier( entry, i );
String[] names = { getIdentifierColumnName() };
identifierGridType.nullSafeSet( associationRow, identifier, names, session );
}
getKeyGridType().nullSafeSet( associationRow, key, getKeyColumnNames(), session );
// No need to write to where as we don't do where clauses in OGM :)
if ( hasIndex ) {
Object index = collection.getIndex( entry, i, this );
indexGridType.nullSafeSet( associationRow, incrementIndexByBase( index ), getIndexColumnNames(), session );
}
// columns of referenced key
final Object element = collection.getElement( entry );
getElementGridType().nullSafeSet( associationRow, element, getElementColumnNames(), session );
RowKeyAndTuple result = new RowKeyAndTuple();
result.key = rowKeyBuilder.values( associationRow ).build();
result.tuple = associationRow;
associationPersister.getAssociation().put( result.key, result.tuple );
return result;