jeeravi wrote:
I am facing similar kind of problem with @Where. Have you found out a way to resolve this problem?
What I do just for now is to define an abstract getter for the field in the superclass, and define the field itself and its mapping annotations in every concrete subclass. It's not perfect, as you can't reuse the annotations. But anyway, all the logic on top of the collections is inherited from the abstract superclass. Of course, you must define the abstract getter too:
public abstract class Superclass {
protected abstract List<Child> internalGetChildren();
public void addChild(Child child) {
internalGetChildren().add(child);
child.setParent(this);
}
public void removeChild(Child child) { .... }
public List<Child> getChildren() { ... }
public double getChildrenValueAverage() { ... }
.....
}
public class Subclass1 extends Superclass {
@OneToMany(mappedBy="parent")
@Where(....)
List<Child> children;
protected List<Child> internalGetChildren() { return children; }
}
public class Subclass2 extends Superclass {
@OneToMany(mappedBy="parent")
@Where(....)
List<Child> children;
protected List<Child> internalGetChildren() { return children; }
}
Cheers,
Carlos