#46 getting the real type of hibernate proxies

Dozer v.5.3.0
closed-accepted
5
2010-09-01
2010-04-27
Tim Nee
No

Added code to always deproxy (assuming HibernateProxy for now) the source object (top level and fields)

The current implementation of DefaultProxyResolver.getRealClass and getRealSuperClass is insufficient for hibernate proxies. This relies on the Class.getSuperclass() to get the real class. When this is call on hibernate proxy, it returns the type of the field but not the true type of the value.

For example:
you have the following classes

class A {...}

class B extends A {...}

class C {
private A a
public A getA() {..}
public void setA(A a){...}
}

if C.a is a hibernate proxy, calling C.getA().getSuperclass() will always return A, even if its value is really of type B.

By always deproxying the source object, please consider deprecating the rest of ProxyResolver and refactoring the proxied tests.

Discussion

  • dmitry (lv)

    dmitry (lv) - 2010-08-04

    Hi,
    Thanks for the patch! I looked through it and will apply your fix soon. One remark is that Hibernate should have its own proxy resolver type, which is configurable. Otherwise this will result in unnecessary performance overhead on non-proxy environments and non-hibernate proxies. I will also introduce NoneProxyResolver for use-cases we are sure there is nothing to unproxy.

     
  • dmitry (lv)

    dmitry (lv) - 2010-08-04
    • milestone: 942315 --> Dozer v.5.3.0
    • assigned_to: nobody --> buzdin
    • status: open --> open-accepted
     
  • dmitry (lv)

    dmitry (lv) - 2010-09-01

    I have applied your patch to trunk. Will be released in 5.3.0. Hibernate comes as an optional implementation and should be enabled in config file.

     
  • dmitry (lv)

    dmitry (lv) - 2010-09-01
    • status: open-accepted --> closed-accepted
     
  • dmitry (lv)

    dmitry (lv) - 2010-09-01

    Abstract type problems are fixed as well.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks