[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2330) If loaded entity is cglib enhanced, FieldInterceptionHelper.injectFieldInterceptor() fails to find the field interceptor interface on the entity, leaving the interceptor null

Riccardo Palombella (JIRA) noreply at atlassian.com
Fri Feb 9 11:29:41 EST 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2330?page=comments#action_26053 ] 

Riccardo Palombella commented on HHH-2330:
------------------------------------------

I also have the same problem.
I have not unit test case, but the issue is very simple to understand.

Basically the FieldInterceptionHelper implementation will never work with any subclass of an instrumented class, because the getInterfaces() method of the java.lang.Class object does not return the interfaces implemented by superclasses.

The way to patch that is very simple and clean.
Substitute the old implementation with a new one that uses the isAssignableFrom(Class) of the java.lang.Class object.

I have already implemented it at my project, I will try to attach it here.

I think it will be very nice if you fix this bug in the next release.
Thaks a lot.

> If loaded entity is cglib enhanced, FieldInterceptionHelper.injectFieldInterceptor() fails to find the field interceptor interface on the entity, leaving the interceptor null
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HHH-2330
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2330
>      Project: Hibernate3
>         Type: Bug

>   Components: core
>     Versions: 3.2.1
>     Reporter: James Sparrow
>     Priority: Critical
>  Attachments: FieldInterceptionHelper.java, patch1
>
>
> After upgrading from Hibernate 3.1.3 to Hibernate 3.2.1, entities with lazy property fetching enabled ceased lazily loading the properties. I tracked this down to a problem in the way FieldInterceptionHelper locates the interceptor interfaces on classes. If the loaded entity (i.e., coming through PojoEntityTuplizer.afterInitialize()) is already cglib enhanced, the FieldInterceptionHandler's use of entity.getClass().getInterfaces() will fail to locate the InterceptFieldEnabled interface on the instrumented superclass of the entity (since getInterfaces() only returns interfaces on the type, not supertypes).
> This can be fixed by retrieving all interfaces on the class and its superclasses (see attached patch).

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list