Hi,
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,
Georges