Fixed an issue with one to many relations

As described in #2325