interfaces for Proxies are not regonized as interfaces

Description

In org.hibernate.tuple.PojoEntityTuplizer line 119 reads:
if ( !proxyInterface.isInterface() ) {
and should be
if ( !subclassClass.isInterface() ) {

So the code then would look like this:

Subclass subclass = ( Subclass ) iter.next();
Class subclassProxy = subclass.getProxyInterface();
Class subclassClass = subclass.getMappedClass();
if ( subclassProxy!=null && !subclassClass.equals( subclassProxy ) ) {
if (

throw new MappingException(
"proxy must be either an interface, or the class itself: " +
subclass.getEntityName()
);
}
proxyInterfaces.add( subclassProxy );
}

After that change the specified interfaces for subclass proxies are regonized as such. Without this patch the superclass is checked, which may not have/be an interface as proxy class.

Environment

Discovered on Hibernate 3.0, still present in 3.1rc3

Activity

Show:
Oleg S. Kobyzev
May 15, 2006, 9:30 PM

Hi ,
I have the same issue in version 3.1.3. Could you please provide me an information about how this isssue can be fixed or how can I get round this issue.

thank you in Advance!

TobiasF
May 16, 2006, 6:22 AM

Unless this is fixed in the source you need to pull the sources, apply the fix youself and compile your own hibernate version.
Another option is to let the superclass use a interface as the proxy. That would be a workaround.

Benoit Goudreault-Emond
April 5, 2007, 9:11 PM

This code sample is a Maven project that builds against 3.2.2 GA and reproduces the problem in the test case (simply run "mvn test").

Briefly, this occurs when subclasses are given interfaces, but the parent class does not implement one. Note how DoctorImpl has a proxy declaration, but not Person.

Why would one do this? Well, in cases where a few extra methods are used only for certain subclasses, it is important to provide them through an interface so they are accessible even if the class returned by Hibernate is a proxy. Putting all methods of the base class in some base interface does fix the problem, but it's an annoying extra step.

Note that even if the bug described here is fixed, there are other problems in those situations, especially in the presence of access="field". I'm currently trying to isolate this. I suspect is related to that problem.

Paul Benedict
June 2, 2008, 5:23 PM

This issue now has a test case. Can it be looked at again for 3.3?

Our development has the same issue: we query for a list of AbstractItems, which implement the Item interface, but the concrete subclasses also have specific interfaces. Currently, we cannot cast to those subinterfaces through a proxy.

Steve Ebersole
March 21, 2011, 7:09 PM

Bulk closing stale resolved issues

Fixed

Assignee

Steve Ebersole

Reporter

TobiasF

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure