@Transient annotation not respected when class defines 'get' and 'is' accessor variants

Description

I encountered the following while porting our application from JBoss EAP 6.4 (Hibernate 4.2) to EAP 7 (Hibernate 5). It occurred with both EAP's bundled 5.0.11, and when I upgraded the provider to 5.2.7. Sorry, I haven't been able to check whether it still exists as of the current 5.2.10.

We had a couple of entities with the pattern below:

Note the convenience method isReported() annotated with @Transient that returns the unwrapped value of the Boolean member. In Hibernate 4.2, isReported() is correctly ignored when the entity is loaded; but under 5.0.11 and 5.2.7 we get the following exception for duplicate accessors:

org.hibernate.MappingException: In trying to locate getter for property [reported], Class [xyz.DataLoadFileEvent] defined both a `get` [public java.lang.Boolean xyz.DataLoadFileEvent.getReported()] and `is` [public boolean xyz.DataLoadFileEvent.isReported()] variant

For reference: https://forum.hibernate.org/viewtopic.php?f=1&t=1043982

Activity

Show:

Vlad Mihalcea May 16, 2017 at 11:46 AM

Applied PR upstream.

Chris Cranford May 3, 2017 at 6:11 AM

The reason this fails presently is because the equality check used doesn't account for the comparison between types that only differ based on Object vs primitive. The work around here would be make sure both the is and get methods return the same type so the equality check doesn't complain.

Fixed

Details

Assignee

Reporter

Labels

Worked in

Components

Fix versions

Affects versions

Priority

Created May 3, 2017 at 4:10 AM
Updated April 1, 2021 at 10:22 AM
Resolved May 16, 2017 at 11:46 AM