[jboss-user] [EJB 3.0] - ClassCastException in Javassist /CGLib

gquintana do-not-reply at jboss.com
Mon Dec 10 05:15:44 EST 2007


I am following the A to B relationship (many to one) where B is abstract and the relationship lazy, I get a ClassCastException:
anonymous wrote : java.lang.ClassCastException: com.mycompany.myproject.MyEntityB_$$_javassist_1
  | 	at com.mycompany.myproject.MyEntityB_$$_javassist_1.getMyEntityB1(EntiteB_$$_javassist_1.java)
  | 	at com.mycompany.myproject.MyServiceImpl.getMyEntityB1FromA(MyServiceImpl.java:68)
  | 
I tried to replace Javassist by CGLib but I got the same:
anonymous wrote : java.lang.ClassCastException: com.mycompany.myproject.MyEntityB$$EnhancerByCGLIB$$22ea3be1
  | 	at com.mycompany.myproject.MyEntityB$$EnhancerByCGLIB$$22ea3be1.getMyEntityB1()
  | 	at com.mycompany.myproject.MyServiceImpl.getMyEntityB1FromA(MyServiceImpl.java:68)
  | 
Here are my entities:
@Entity
  | public class MyEntityA {
  |     @Id
  |     private int id;
  |     private String name;
  |     @ManyToOne(fetch=FetchType.LAZY)
  |     private MyEntityB myEntityB;
  | 	...
  | }
  | @Entity
  | @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
  | public abstract class MyEntityB {
  |     @Id
  |     private int id;
  |     private String name;
  |     @OneToMany(mappedBy="MyEntityB")
  |     private List<MyEntityA> myEntitiesA=new ArrayList<MyEntityA>();
  | 	...
  | }
  | @Entity
  | public class MyEntityB1 extends MyEntityB {
  |     @OneToMany(mappedBy="myEntityB1")
  |     private List<MyEntityB2> myEntitiesB2=new ArrayList<MyEntityB2>();
  | 	...	
  | }
  | @Entity
  | public class MyEntityB2 extends MyEntityB {
  |     @ManyToOne
  |     private MyEntityB1 myEntityB1;
  | 	...
  | }
  | 

Can you tell me where I am wrong?

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

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



More information about the jboss-user mailing list