java - JPA relations and polymorphism -
i have following class structure (details omitted clarity):
for example:
@entity class a{ @onetomany private list<b> b; @onetoone private c c; } interface b { } @entity @inheritance abstract class babstract implements b { } @entity @primarykeyjoincolumn class b1impl extends babstract { } @entity @primarykeyjoincolumn class b2impl extends babstract { }
i want load b's belonging c. class relates b c. b , c unaware of each others existence , keep way. don't know actual implementing type of b , don't care because use abstract data type b (the interface). implementation can vary on time, example, new implementation of b can added in future in new release.
is possible jpa , how do that? can't use targetentity attribute, if i'm correct, because don't know implementing class , don't care. b polymorph.
jpa doesnt work interfaces. need make b @ least abstract class entity annotation. can make b totally empty abstract class (except id field, need that) , add inheritance. reason in order entity have reference entity, there must way reference entity in database - , if there no table b there no way that.
Comments
Post a Comment