Hello,
Having the following entities (truncated for brevity):
@Entity(name = "Car")
@FilterDef(
name="carColor",
parameters = @ParamDef(name="color", type="string")
)
@Filter(name="activeAccount", condition="car_color = :color")
public class Car {
@Id
private UUID id;
@Column(name = "car_color")
private String color;
private String specifications;
private int numOfDoors;
@OneToMany(fetch = FetchType.LAZY)
private Set<Part> parts = new HashSet<>(0);
}
and
@Entity(name = "Part")
public class Part {
@Id
private UUID id;
@ManyToOne(fetch = FetchType.LAZY)
private Car car;
private long partNumber;
//..other car part properties...
}
and then activating the filter:
entityManager
.unwrap( Session.class )
.enableFilter( "carColor" )
.setParameter( "color", "black");
would, joining the two entities as in the following query, activate the filter in Car:
entityManager.createQuery("select p from Part p join p.car c where p.partNumber = :pn", Part.class)
.setParameter("pn", 34934238)
.getResultList();
If not, is there a way to achieve that?
Thanks.