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
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user