Fix for using native SQL-Query loaders with a many to many relationship. This fix was borrowed from a fix made for the same bug in Hibernate (detailed here https://hibernate.atlassian.net/browse/HHH-2745)