0
我有一個簡單的模型,帶有許多關係和函數,可以渲染模型頁面,如下所示。我想知道是否有篩選按類別像.ilike("categories", "%" + filter + "%")
在Play中通過ManytoMany關係過濾模型對象! 2.0
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);
}
}