PluralAttribute.getPersistentAttributeType() wrong value with enhanced classes

Description

When using compile-time enhancement, PluralAttribute.getPersistentAttributeType() returns PersistentAttributeType.ONE_TO_MANY for all plural (collection) associations.

The problem, maybe, is inside:

org.hibernate.jpa.internal.metamodel.AttributeFactory.java

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.

Environment

Hibernate 5.0.7

Activity

Show:
Luis Barreiro
March 22, 2016, 3:01 AM

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.

Gail Badner
March 22, 2016, 9:31 PM
Edited

, I'll take a look at your pull request when you have one, then decide about backporting to 5.0.

Steve Ebersole
June 9, 2016, 4:12 PM

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!

Gail Badner
June 10, 2016, 10:46 PM

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.

Gail Badner
June 10, 2016, 11:23 PM

Fixed in 5.1 and 5.0 branches as well. Thanks Luis!

Fixed

Assignee

Luis Barreiro

Reporter

Michele Mariotti

Fix versions

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure