Generic DAO search with group by / unqiue

318 Views Asked by At

I am using hibernate-generic-dao for a searching function. Since I only need to show one of the records if they have same value on a column field. But I am not sure how to achieve this by the search / filter functions.

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

There are 1 best solutions below

0
Christian Beikov On

You should probably ask this question by opening an issue in the repository for that project here: https://github.com/vincentruan/hibernate-generic-dao

It seems though as if the project is abandoned, so unless you feel like digging into the details, you should probably try to get away from it.