lundi 23 mai 2016

Inheritance mapping Hibernate: Relation mapping between two subclasses

I have three entities A, B and C.

class A{
     Long id;
}
class B extends A{
   //  var1, var2
   List<C> var0;
}

class C extends A{
    //var 3, var4
    List<B> var5;
}

B and C both extends A, also B should contain list of C and C should contain list of B.

Now for inheritance mapping I have used single table strategy, as B and C are almost identical.

When I try to define ManyToMany relationship between B and C, so that I can have a mapping of them. My join column have the same name. SO its throwing error which is : org.hibernate.MappingException: Repeated column in mapping for collection

I am not sure if its the right way to do that. Or is there a way around for it?

Aucun commentaire:

Enregistrer un commentaire