The error I am receiving is the following:
I understand from the error there seems to be a problem with the mapping I have. This is the code I have:
I've been debugging this issue, and found out the possible root of the problem is related to this method inside CollectionMetadataGenerator.
In this case, it seems to fail to find the correct mapping. In the specific comparison in Tools.iteratorsContentEqual() call, one of the params is an object representing the CompositeKey (Both columns as expressed by the IdClass), but in the other parameter is only the column related to the specific column that maps the Company object based on the inverse relation. So when comparing it fails and return null. I think that in this cases the comparison should look if the ColumnIterator returns a CompositeKey and in such case compare to find at least a column inside that matches the specific column return in the inverse relation.
P.S. I am trying to flag this in the 4.1.7 version but it seems it has not been created at the moment