我有一个具有多对多关系和函数的简单模型,可以渲染模型页面,如下所示。我想知道是否有办法按类别(ManytoMany 字段)过滤项目页面,例如.ilike("categories", "%" + filter + "%")
public class Item extends Model {
@Id
public Long id;
@ManyToMany(fetch=FetchType.EAGER, cascade=CascadeType.ALL)
public List<Category> categories = new ArrayList<Category>();
public String title;
@Formats.DateTime(pattern="dd/MM/yyyy")
public Date postDate=new Date();
public String content;
public String picture;
public String price;
public String url;
public static Finder<Long,Item> find = new Finder<Long,Item>(
Long.class, Item.class
);
public static Page<Item> page(int page, int pageSize, String sortBy, String order, String filter) {
return
find.where()
.ilike("content", "%" + filter + "%")
.orderBy(sortBy + " " + order)
.findPagingList(pageSize)
.getPage(page);
}
}