| 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.
public interface Trashable
{
/**
* 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);
}
public interface PageElement extends Trashable, Serializable
{
[snip]
}
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 ....
{
if ( getter == null ) {
for ( Class theInterface : containerClass.getInterfaces() ) {
getter = getGetterOrNull( theInterface, propertyName );
if ( getter != null ) {
break;
}
}
}
}
to something like ....
{
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. |