java - mappedBy reference an unknown target entity property with inheritance -
i trying store entity inside database hibernate. have got following classes:
@entity public class usableremoteexperiment extends remoteexperiment { private list<experimentnodegroup> nodegroups = new arraylist<>(); @onetomany(mappedby = "experiment", cascade = cascadetype.all, orphanremoval = true) public list<experimentnodegroup> getnodegroups() { return nodegroups; } public void setnodegroups(final list<experimentnodegroup> nodegroups) { this.nodegroups = nodegroups; } /* more getters , setters other attributes */ the experiment node group looks this:
@entity public class experimentnodegroup extends nodegroup { private list<node> nodes = new arraylist<>(); /* more getters , setters other attributes */ and nodegroup class looks this:
@entity public abstract class nodegroup extends generatedidentity { protected experiment experiment; @manytoone(optional = false) @jsonignore public experiment getexperiment() { return experiment; } /* more getters , setters other attributes */ now when try compile code, error:
caused by: org.hibernate.annotationexception: mappedby reference unknown target entity property: [...].experimentnodegroup.experiment in [...].usableremoteexperiment.nodegroups
it's 1 of quirks of hibernate not work expected mappedby , inheritance. try specifying targetentity well? here's documentation , says:
the entity class target of association. optional if collection property defined using java generics. must specified otherwise.
you can try specifying targetentity = experimentnodegroup.class or targetentity = transaction.class , see if makes difference.
Comments
Post a Comment