Hi,
I'm trying to filter Offers based on the property Region from a manytoone association with City.
I understand I have to place the filter on Offer and that I can use arbitrary sql in the condition but I don't understand how I would phrase the sql.
Initially I thought placing the filter on City would do the trick, but there seems to be no "magical" detection of filters on associations like these.
I have the following classes
Code:
@Entity
@Filter(name="region", condition="[???]")
@FilterDef(name="region", parameters=@ParamDef(name="regionId",type="java.lang.Long"))
Offer
@Embedded
Address address;
@Embeddable
Address
@ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
@JoinColumn(name = "FK_CityID")
City city;
@Entity
City
@ManyToOne(optional=true,cascade=CascadeType.MERGE,fetch=FetchType.LAZY)
@JoinColumn(name="FK_regionID", nullable=true)
Region region;
@Entity
Region
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="regionId", nullable=false, insertable=false, updatable=false)
public Long getId() {
return id;
}
Any ideas on how to solve this? Is is at all possible using filters?
Kind regards,
Marc