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.
{code:java|title=Trashable.java} 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); } {code}
{code:java|title=PageElement.java} public interface PageElement extends Trashable, Serializable { [snip] } {code}
{code:java|title=ContentElement.java} public interface ContentElement extends PageElement { [snip] } {code}
Since ReflectUtil only looks at the parent interfaces instead of all ancestors, the interface can no longer be mapped.
Changing from .... {code:java|title=ReflectHelper.java#409} { // 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; } } } } {code} to something like .... {code:java|title=ReflectHelper.java#409} { // 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; } } } } {code} would fix this. |
|