Hello list,
I am running into an exception and don't know, what it tells me. But first, two words about what I am doing:
I have an entity that I need to map. The entity contains an embedded object, which is derived from a base class. In code:
Code:
@Entity
class MyEntity {
@Embedded
private BasicObject object;
and
Code:
@Embeddable
class BasicObject extends VeryBasicObject {
and
Code:
@MappedSuperclass
class VeryBasicObject {
The situation, as given above, works! I can map the values in VeryBasicObject to columns and all is fine. But now: Out of various reasons I have the requirement to use an XML mapping (orm.xml) for the VeryBasicObject class.
Should be no problem, I'd think. Just remove the @MappedSuperclass annotation and add <mapped-superclass name="..."/> to the orm.xml.
But when I try that I get this exception:
javax.persistence.PersistenceException: java.lang.ClassCastException: $Proxy3
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:217)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
...
Caused by: java.lang.ClassCastException: $Proxy3
at org.hibernate.reflection.java.EJB3OverridenAnnotationReader.getMappedSuperclass(EJB3OverridenAnnotationReader.java:1688)
at org.hibernate.reflection.java.EJB3OverridenAnnotationReader.initAnnotations(EJB3OverridenAnnotationReader.java:285)
The exception comes when the EntityManagerFactory is created. I have stripped the code down to a test class and three small pojos and can reproduce the exception. I don't know if I can attach the eclipse project zip here somewhere, but it doesn't look that way. So, if you think it would help to have the reproducing eclipse project, drop me a note and I will send the thing to you by email, it is only 9kB. (The classpath of the project is left empty, I guess you'll know what you have to add to it for hibernate to work :-)).
I am using Hibernate 3.2.0.cr2, EntityManager 3.2.0.cr1 and Annotations 3.2.0.cr1.
Best wishes, Daniel