Hi, is it possible to use object property values with @Filter annotation?
For example, we have:
Child:
Code:
@Entity public class Child{
@Column(name="id")
public Integer id;
@Column(name="surname")
public String surname;
}
Parent:
Code:
@Entity public class Parent{
@Column(name="id")
public Integer id;
@Column(name="surname")
public String surname;
@ManyToMany(fetch=FetchType.EAGER)
@JoinTable(
name="parents_children",
joinColumns = @JoinColumn(name = "parent_id", referencedColumnName="id"),
inverseJoinColumns = @JoinColumn(name = "children_id", referencedColumnName="id")
)
@Filter(name="propertyFilter", condition="children.surname = parent.surname")
public List<Children> children;
}
What I try to accomplish is this line:
Code:
@Filter(name="propertyFilter", condition="children.surname = parent.surname")
I want to filter the collection, to leave only children with the same surname as parent.
How can I do this? Any other methods?