saperliu / hibernate-generic-dao

Automatically exported from code.google.com/p/hibernate-generic-dao
0 stars 0 forks source link

OP_LIKE is not working #116

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. When i add like filter it is not wokring but others filters are working. 
Problem at "OP_LIKE". can you help me to solve this problem/. I use jquery 
datatable. i have filter segment on table. when i write something or on first 
loading. there is no data on datatable because of the filter segment. 
criterias.getSearch() is working good. Problem at this row

Filter f = new Filter("name", criterias.getSearch(), Filter.OP_LIKE);
        search.addFilter(f);

my full method is below/

@Override
    public DataSet<AgeRangeDTO> findAgeRangeWithDatatablesCriterias(DatatablesCriterias criterias) {

        Search search = new Search(AgeRange.class);

        Filter f = new Filter("name", criterias.getSearch(), Filter.OP_LIKE);
        search.addFilter(f);

        // sorting
        final List<ColumnDef> sortingColumnDefs = criterias.getSortingColumnDefs();

        if (!CollectionUtils.isEmpty(sortingColumnDefs)) {

            for (ColumnDef columnDef : sortingColumnDefs) {

                final ColumnDef.SortDirection sortDirection = columnDef.getSortDirection();
                switch (sortDirection) {
                case ASC:
                    search.addSort(columnDef.getName(), true);      
                    break;
                case DESC:
                    search.addSort(columnDef.getName(), false);
                    break;
                }

            }
        }
        search.setMaxResults(criterias.getDisplaySize());
        search.setPage(criterias.getDisplayStart());

        SearchResult<AgeRange> result = ageRangeDAO.searchAndCount(search);

        List<AgeRangeDTO> dtoList = new ArrayList<AgeRangeDTO>();
        for (AgeRange obj : result.getResult()) {
            AgeRangeDTO dt = new AgeRangeDTO();
            dt.setId(obj.getId());
            dt.setDescription(obj.getDescription());
            dt.setName(obj.getName());
            dt.setEnabled(obj.getEnabled());
            dtoList.add(dt);
        }

        DataSet<AgeRangeDTO> dataset = new DataSet<AgeRangeDTO>(dtoList, new Long(result.getTotalCount()), new Long(criterias.getDisplaySize()));

        return dataset;
    }

Original issue reported on code.google.com by ozalpnuri on 22 Feb 2015 at 11:19