After upgrading from version 3.2.6 to version 3.3.2 I came across a situation where hibernate throws an exception (if using Javassist bytecode provider). I am registering this as a bug type issue and would very much appreciate your kind input on this subject.
Please find attached a testcase for the hibernate-testsuite module that demonstrates this issue.
The exception is thrown because the lazy initialization proxy is not able to find a setter method of a domain.
It does not find the setter method because the domain is composed of an abstract class and a concrete class, which I shall refer to as AbstractOverloaded and Overloaded, respectively.
AbstractOverloaded defines the setter method "public void setName(String name)" which receives a parameter of type String as defined in the mapping.
Overloaded extends AbstractOverloaded and defines the method "public void setName(Integer name)" which overloads the previous method.
When the JavassistLazyInitializer loads an instance of Overloaded, the proxy returned throws an exception if you try to execute the statement overloadedProxy.setName("Manuel"), because it cannot find the method defined in the AbstractOverloaded (super class) class.
On the other hand, when you create a proxy of the Overloaded class by using javassist directly then the same statement overloadedProxy.setName("Manuel") works well.
I am aware that I could configure hibernate to use the CGLIB bytecode provider instead, which would prevent the exception from occurring. However since Hibernate adopted Javassist as their bytecode provider of choice and I prefer to stick to your standards and not deviate from the recomended dependencies.
I look forward to your recomendations.
Kind regards
Martins
|