Hi, Please help me out to write the following in Criteria or Example Query :-
StringBuilder SQLquery=new StringBuilder(); SQLquery.append(" select dbo.getSearchString(qr.id) as queryString,qr.resultCount as resultCount, qr.dateFound as dateFound from SolrQLog.QueryResult qr where dateFound >= ? and dateFound <= ? group by qr.id, resultCount, dateFound order by "); if(sortType == null){ SQLquery.append(" resultCount"); }else if(sortType.equalsIgnoreCase("Search String")){ SQLquery.append(" queryString"); }else if(sortType.equalsIgnoreCase("Date")){ SQLquery.append(" dateFound"); }else{ SQLquery.append(" resultCount"); }
List<SearchResults> allList = getSession().createSQLQuery(SQLquery.toString()) .addScalar("queryString", Hibernate.STRING) .addScalar("resultCount", Hibernate.INTEGER) .addScalar("dateFound", Hibernate.DATE) .setResultTransformer(Transformers.aliasToBean(SearchResults.class)) .setString(0, fromDate) .setString(1, toDate) .list();
In the above getSearchString is a DB function and sortType is the parameter passed to that DAO method.
Thanks, Utpal
|