* </ol>
* So the same RowKey cannot be created for two different associations at the same time from within the same
* transaction.
*/
private PropertyContainer createRelationshipToEntityOrToTempNode(AssociationKey associationKey, RowKey rowKey) {
Node rowKeyNode = neo4jCRUD.findNode( rowKey );
// Check if there is an entity or a temporary node representing the RowKey
if ( rowKeyNode == null ) {
if ( associationKey.getAssociationKind() == AssociationKind.EMBEDDED_COLLECTION ) {
return createNodeAndAddRelationship( associationKey, rowKey, NodeLabel.EMBEDDED );
}
else {
// We look for the entity at the end of the association, if we cannot find it
// we save the RowKey in a temporary node.
return findEntityOrCreateTempNode( associationKey, rowKey );
}
}
else if ( rowKeyNode.hasLabel( ENTITY ) ) {
// The RowKey represents an entity and we are going to create the relationship to it
return createRelationshipWithEntity( associationKey, rowKey, rowKeyNode );
}
else if ( rowKeyNode.hasLabel( TEMP_NODE ) ) {
// We have found a temporary node related to this association, we are going to delete it and connect the
// entity pointing to the temporary node and the owner of this association.
return deleteTempNodeAndCreateRelationshipWithEntity( associationKey, rowKey, rowKeyNode );
}
else {