Polymorphism, lazy initialization and @ContainedIn don't work well together

Description

Hi,

Following our recent posts on using Lazy initialization with Hibernate Search, we have one (hopefully) final problem: when we have a complex hierarchy of @IndexedEmbedded and @ContainedIn using polymorphism, we have an exception in the ReflectionHelper.getMemberValue() call of AbstractDocumentBuilder.appendContainedInWorkForInstance().

In our example, we reference a field which is in the child class and the lazy Javassist proxy is based on the parent class, so when you try to get the member value via reflection, you have an exception as the field doesn't exist in the proxy.

We fixed the issue by unproxying the instance before manipulating the object.

Pull request to come, with a test case contributed by my colleague Yoann Rodière (corporate CLA on its way).

Environment

None
Fixed

Assignee

Guillaume Smet

Reporter

Guillaume Smet

Labels

None

Suitable for new contributors

None

Pull Request

None

Feedback Requested

None

Components

Fix versions

Affects versions

Priority

Major
Configure