java - JPARepository's findAll query on baseclass of @MappedSuperClass just returns entries of baseclass -
java - JPARepository's findAll query on baseclass of @MappedSuperClass just returns entries of baseclass -
i have jpa mappedsuperclass this:
@mappedsuperclass public abstract class foo extends abstractpersistable<long> { private status status; @manytoone(cascade=cascadetype.all) private user owner;
and 2 subclasses inheriting foo, namely defined follows:
@entity @table(name="barfoo") @equalsandhashcode(callsuper=true) @primarykeyjoincolumn(name="id", referencedcolumnname="id") public @data class bar extends foo { private string beer;
and
@entity @table(name="blubfoo") @equalsandhashcode(callsuper=true) @primarykeyjoincolumn(name="id", referencedcolumnname="id") public @data class blub extends foo { private string cider;
now when save info in object of type bar or blub expect myrepository.findall homecoming cider or beer , both status , owner mappedsuperclass. instead, returns cider or beer - properties of subclass.
is there error in reasoning or missing on completely?
this barrepository:
public interface barrepository extends jparepository<bar, long> { }
and how findall() in barservice "implemented":
@inject private barrepository barrepository; public iterable<bar> findall() { homecoming barrepository.findall(); }
i have both blub subclass. hint appreciated , when missed on best practice, i'd glad if set me on right track again.
java hibernate jpa
Comments
Post a Comment