Fix infinite loop in unit of work on bidirectional references with discriminator maps