我正在使用 hibernate-generic-dao 进行搜索功能。因为如果它们在列字段上具有相同的值,我只需要显示其中一条记录。但我不确定如何通过搜索/过滤功能来实现这一点。
package com.googlecode.genericdao.search;
PersonContact domain object:
...
@Column(name = "group_key", length = 20)
public String getGroupKey() {
return groupKey;
}
@Formula(value = "(SELECT status from person_contact m " +
" WHERE m.case = case AND m.movement_id = movement_id )")
public String getActiveRecord() {
return activeRecord;
}
...
Search search = new Search();
search.addFilterNotNull("groupKey"); //groupKey is the field I want to use "group by / unqiue" with it
search.addFilterEqual("type","C");
search.addFilterCustom("{activeRecord} != 'I' ");
search.setMaxResults(limit);//for paging
search.setFirstResult(startIdx);
SearchResult<PersonContact> resultObj = PersonContactDAO.searchAndCount(search);