0

検索機能に hibernate-generic-dao を使用しています。列フィールドに同じ値がある場合、レコードの 1 つだけを表示する必要があるためです。しかし、検索/フィルター機能でこれを実現する方法がわかりません。

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);
4

1 に答える 1