[jboss-user] Hibernate proxy class problem

samk at twinix.com samk at twinix.com
Tue Nov 24 06:18:12 EST 2009

See Thread at: http://www.techienuggets.com/Detail?tx=15288 Posted on behalf of a User


did you resolve your issue?
I have the same problem and am searching for a solution to solve it?

Best Regards,

In Response To: 


I'm having the following odd situation:

  | @Entity 
  | @Inheritance(strategy = InheritanceType.JOINED)
  | public abstract class Customer { @Id private int id; }
  | @Entity 
  | public class SomeCustomer extends Customer { private String name; }

I'm using Entity Manager to retrieve entities by their primary key:

  | entityManager.find(Customer.class, 5);

The primary key 5 belongs to a SomeCustomer entity. It's in the id field of both Customer and SomeCustomer tables (due to join inheritance). However, the query returns an object that has the type Customer_$$_javassist_16 that cannot be cast to SomeCustomer (ClassCastException).
However, if I execute the following query:

  | entityManager.find(SomeCustomer.class, 5);

I will see a warning in my logfile: ProxyWarnLog: Narrowing proxy to class SomeCustomer - this operation breaks ==
Subsequent call to the first find() query will now also return the right object of the right type.

Does anybody know what's going on here or how I can manually narrow down my proxy object to what I want to have if it fails?

Thanks a lot,

More information about the jboss-user mailing list