When using compile-time enhancement, PluralAttribute.getPersistentAttributeType() returns PersistentAttributeType.ONE_TO_MANY for all plural (collection) associations.
The problem, maybe, is inside:
where Field.getAnnotation(ManyToMany.class) is called on the enhanced/generated field which doesn't have the annotation.
It should be called on the original field.
This is not caused by the enhancement itself, as it does not change the entity annotations, but it's caused by a special Getter that we have for enhanced entities. To be more precise, the value returned by getMember() is not correct.
, I'll take a look at your pull request when you have one, then decide about backporting to 5.0.
Applied to upstream master (5.2.1). Thanks again Luis!
this is all ready to go for 5.2; please resolve/close after you decide what to do wrt 5.0/5.1. Thanks!
I've pushed the commits to 5.1 and 5.0 branches.
I have also added a commit to master and 5.1 branches to restore and deprecate org.hibernate.property.access.spi.EnhancedGetterMethodImpl.
For 5.0 branch, I added a commit to restore and deprecate org.hibernate.property.access.spi.EnhancedGetterMethodImpl and EnhancedSetterImpl. EnhancedSetterImpl was already removed in 5.1.
These classes were restored to avoid breaking custom Tuplizer and PropertyAccess implementations that use them.
EnhancedGetterMethodImpl will be removed by HHH-10832.
Fixed in 5.1 and 5.0 branches as well. Thanks Luis!