Batch query processing in foreign ref mapping

Bugfix. Error may lead to ArrayIndexOutOfBoundsException or OutOfMemory
when batch reading 1:N-mappings in random order. 

New test with mocks for this case.