BytecodeProviderImpl.findAccessor only looks at declared methods but is called for an inherited property

Description

BytecodeProviderImpl.findAccessor() throws an exception when called to find the accessor method for a property that is inherited:

This is likely because it relies only on clazz.getDeclaredMethod( name, params ) and nothing outside it:

The method names that end up passed to the above findAccessor() method are discovered based on the methods that have already been found, which brings the question as to why do they need to be found again as well. The code that discovers them before does iterate over subclasses to find them all - the following code is in ReflectHelper:

But the code in PojoEntityTuplizer then gets their names only and passes those names on, instead of the methods themselves. The following is a relevant snippet from the PojoEntityTuplizer constructor and it has a possibly relevant "todo" comment in there:

I cannot create a small yet comprehensive test case yet, unfortunately.

Additional notes

  1. Mapping is loaded from (legacy) *.hbm.xml files. Code has no relevant annotations.

  2. Entity bytecode is enhanced by the hibernate-enhance-maven-plugin with enableLazyInitialization, enableDirtyTracking and enableAssociationManagement set to true and enableExtendedEnhancement set to false. Despite the bytecode enhancement with lazy initialization enabled and indicated as successful (Successfully enhanced class [...]), BytecodeEnhancementMetadataPojoImpl instance for the problem class, at the time when the exception is thrown, has the enhancedForLazyLoading field set to false. I looked at the enhancer code and it seems that enhancement isn't done for unannotated classes (mapped via XML files). This may be an unrelated issue or may indicate a possibility of a workaround. EDIT Added annotations, verified that the bytecode is indeed enhanced (by decompiling it and seeing enhancedForLazyLoading==true) and the issue is still present.

  3. I am not aware of any workarounds - I would appreciate if someone could identify them.

Environment

None

Assignee

Unassigned

Reporter

A Susnjar

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Feedback Requested

2018/06/25

Feedback Requested By

Guillaume Smet

Components

Affects versions

Priority

Major
Configure