【问题标题】:Generic DAO search with group by / unqiue使用 group by / unique 进行 Genericdao 搜索
【发布时间】:2021-08-28 00:32:28
【问题描述】:

我正在使用 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);

【问题讨论】:

    标签: java hibernate group-by distinct hibernate-generic-dao


    【解决方案1】:

    您可能应该通过在该项目的存储库中打开一个问题来提出这个问题:https://github.com/vincentruan/hibernate-generic-dao

    看起来好像项目被放弃了,所以除非你想深入研究细节,否则你应该尽量远离它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-20
      • 2015-10-30
      • 2012-08-29
      相关资源
      最近更新 更多