1 Reply Latest reply on Jan 12, 2009 7:35 AM by Haibo Qiao

    Load inherited type with Home.find()

    Haibo Qiao Newbie
      Dear All,

      I have an inheritance hierarchy in my entities, as:


           @Entity
           @DiscriminatorColumn(...)
           public class Door{
           }
           @Entity
           @DiscriminatorValue("door1")
           public class Door1 extends Door{
           }
           @Entity
           @DiscriminatorValue("door2")
           public class Door2 extends Door{
           }


           ...
           Door door = doorHome.find();
           ...


      when I use doorHome.find() to load a door instance, seems what I get is a proxy(sth like **javassit**), instead of the explicit type(eg, Door1 or Door2), therefore I can't invoke those overriding methods in subclasses.
      This happens when the find() method is called within a conversation, elsewhere it worked fine.

      I'm sure that, the actual instance referenced by the proxy has explicit type, becoz when I clone door I get an instance of its actual type.

      How should I get the reference of the actual object instead of its proxy?

      Thanks,
      HB