4 Replies Latest reply on Apr 10, 2011 8:54 PM by Viacheslav Garmash

    hibernate proxy and typecast

    porcherg Novice

      With Hibernate, a proxy is used for lazy associations. The real object is only fetched from the database when accessed. But for polymorphic association, the proxy is a subclass of the top level class. Any call to "instanceof" or isAssignableFrom... does not work.

      This is an issue for example in WireContext, because we check if a descriptor is an instance of Initializable during it's construction.

      In this post http://www.mail-archive.com/hibernate-devel@lists.sourceforge.net/msg02307.html, it is said that a solution is to use outer-join fetching (= disabling lazy loading) or to explicitly load the object from the session.

      Is there any other solution for this issue ?