We're updating the issue view to help you get more done. 

@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:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 package xyz; <imports omitted...> /** * An audit of the processing of a data load file, both automatically and manually initiated steps, starting from the * discovery of the file and ending with the archiving of the file. */ @Entity public class DataLoadFileEvent { <unrelated members omitted...> private Boolean reported; public DataLoadFileEvent() { } public void setReported(Boolean reported) { this.reported = reported; } public Boolean getReported() { return this.reported; } @Transient public boolean isReported() { boolean ret = false; if (reported != null) { ret = reported; } return ret; } }

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

Environment

Windows 7, SQL Server 2012
Red Hat JBoss EAP 6.4.5

  • Hibernate 4.2.21.Final-redhat-1
    Red Hat JBoss EAP 7.0.3

  • Hibernate 5.0.11.Final-redhat-1

  • Hibernate 5.2.7.Final

Status

Assignee

Andrea Boriero

Reporter

David Carr

Fix versions

backPortable

None

Suitable for new contributors

Yes, likely

Requires Release Note

None

backportDecision

None

Worked in

4.2.21

Components

Affects versions

5.0.11
4.3.0.Final
5.2.7

Priority

Minor