xerces8 (1) [Avatar] Offline
#1
Hi!

In the book in 4.4.1 "Retrieving objects by identifier" it says :
get() never returns a proxy.


But in our code, it does.

We use JBoss 4.0.4GA (includes hibernate 3.2.0.cr2) and the code looks like this :

Foo foo = session.get(Foo.class, someID);
session.flush();
session.evict(foo);
session.flush();
...
session.get(foo.getClass(), foo.getID()); // BOOM


If we run this code twice in a row with the same (String) value of someID, the returned object (foo) in the second case is not of type Foo, but Foo$$EnhancerByCGLIB$$f6f2dbd7.

Therefore the second get() (line commented with BOOM) fails with :
org.hibernate.MappingException: Unknown entity: Foo$$EnhancerByCGLIB$$f6f2dbd7

Any idea what is going on ?
How to avoid the problem ?

Regards,
David

(the above code is run inside a Bean, transactions are used)