PropertyAccessBuildingException: Could not locate getter for property named [...ContentElement#trashed]

Description

We're upgrading from 4.3 to 5.2 of hibernate and ran into a regression.

I have an interface mapped with XML that will no longer get mapped due to a change in how properties are resolved.

ContentElement -> PageElement -> Trashable.

Trashable.java

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 public interface Trashable { // Consider adding a "date trashed" and "user" properties. /** * Get the name of the trashable item. * * @return the name. */ String getName(); /** * Get the site the trashable item belongs. * * @return the site. */ Site getSite(); /** * Return true if the element is trashed. * * @return true or false. */ boolean isTrashed(); /** * Set the trashed value. * * @param value the value. True indicates the entity is in the trash. */ void setTrashed(boolean value); }

PageElement.java

1 2 3 4 public interface PageElement extends Trashable, Serializable { [snip] }

ContentElement.java

1 2 3 4 public interface ContentElement extends PageElement { [snip] }

Since ReflectUtil only looks at the parent interfaces instead of all ancestors, the interface can no longer be mapped.

Changing from ....

ReflectHelper.java#409

1 2 3 4 5 6 7 8 9 // if no getter found yet, check all implemented interfaces if ( getter == null ) { for ( Class theInterface : containerClass.getInterfaces() ) { getter = getGetterOrNull( theInterface, propertyName ); if ( getter != null ) { break; } } }

to something like ....

ReflectHelper.java#409

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 // if no getter found yet, check all implemented interfaces if (getter == null) { ArrayDeque<Class<?>> stack = new ArrayDeque<>(); for (Class<?> aClass : containerClass.getInterfaces()) stack.push(aClass); while(!stack.isEmpty()) { Class<?> theInterface = stack.pop(); for (Class<?> aClass : theInterface.getInterfaces()) stack.push(aClass); getter = getGetterOrNull(theInterface, propertyName); if (getter != null) { break; } } }

would fix this.

Environment

Hibernate 5.2.7
PostgreSQL 9.5.5

Status

Assignee

Unassigned

Reporter

RussT

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

4.3.11

Components

Affects versions

5.2.7

Priority

Major
Configure