1 Reply Latest reply on Jul 18, 2008 4:19 AM by sere dsds

    hibernate Session.get() returns proxy ?

    davidbalazic Newbie

      (I posted this first on hibernate.org forums, but got no reply)


      I have this with hibernate 3.2.0.cr2 (inside JBoss 4.0.4GA):

      Mapped m = session.get(Mapped.class,myID);
      // ...

      This runs once, and then again (the value of myID is the same).
      On the second run, the get(Mapped.class,myID) returns an object of type Mapped$$EnhancerByCGLIB$$f6f2dbd7 instead of Mapped, so the line session.get(m.getClass,m.getID()); fails as it will try to load an object of type Mapped$$EnhancerByCGLIB$$f6f2dbd7 , but that has no defined mapping.
      I get :

      Caused by: org.hibernate.MappingException: Unknown entity: Mapped$$EnhancerByCGLIB$$f6f2dbd7

      Why does it return in the second case this weird object (I guess it is a proxy) instead of a normal object, like in the first iteration (it is basically a loop).
      How do I force it return a plain object ?
      The book "Hibernate in Action" says in 4.4.1 "Retrieving objects by identifier" it:
      get() never returns a proxy.

      But in my case it does ???