[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - hibernate Session.get() returns proxy ?

davidbalazic do-not-reply at jboss.com
Mon Mar 19 06:42:18 EDT 2007


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

Hi!

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

  | Mapped m = session.get(Mapped.class,myID);
  | session.flush();
  | session.evict(m);
  | session.flush();
  | // ...
  | session.get(m.getClass,m.getID());
  | 

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 ???

Regards,
David

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4029254#4029254

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4029254



More information about the jboss-user mailing list