Example usage for org.hibernate Query setResultTransformer

List of usage examples for org.hibernate Query setResultTransformer

Introduction

In this page you can find the example usage for org.hibernate Query setResultTransformer.

Prototype

@Deprecated
Query<R> setResultTransformer(ResultTransformer transformer);

Source Link

Document

Set a strategy for handling the query results.

Usage

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.SubdomainRepositoryHibernate.java

License:Open Source License

@Override
public List<Map<String, Object>> getSubdomainStandards(Integer subdomainId, String[] rootNodeId) {
    Query query = getSession().createSQLQuery(SUBDOMAIN_STANDARDS);
    query.setParameter(SUBDOMAIN_ID, subdomainId);
    query.setParameterList(ROOT_NODE_ID, rootNodeId);
    query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
    return list(query);
}

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.SubdomainRepositoryHibernate.java

License:Open Source License

@Override
public List<Map<String, Object>> getStandards(Integer codeId, String[] rootNodeId) {
    Query query = getSession().createSQLQuery(STANDARDS);
    query.setParameter(CODE_ID, codeId);
    query.setParameterList(ROOT_NODE_ID, rootNodeId);
    query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
    return list(query);
}

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.SubjectRepositoryHibernate.java

License:Open Source License

@Override
public List<Map<String, Object>> getCourses(int offset, int limit, int subjectId) {
    Query query = getSession().createSQLQuery(COURSES).setParameter(SUBJECT_ID, subjectId);
    query.setMaxResults(limit != 0 ? (limit > MAX_LIMIT ? MAX_LIMIT : limit) : limit);
    query.setFirstResult(offset);/*from  w  w w. j  a  v  a 2s  .c o m*/
    query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
    return list(query);
}

From source file:org.egov.egf.web.actions.report.BudgetAppropriationReportAction.java

License:Open Source License

@SuppressWarnings("unchecked")
private void populateReAppropriationData() {
    setRelatedEntitesOn();/* ww w. j  ava  2  s. c  om*/
    final Query query = generateQuery();
    query.setResultTransformer(Transformers.aliasToBean(BudgetReAppReportBean.class));
    budgetDisplayList.addAll(query.list());
}

From source file:org.egov.egf.web.actions.report.DepartmentwiseExpenditureReportAction.java

License:Open Source License

public void populateDaywiseTotal() {
    if (LOGGER.isInfoEnabled())
        LOGGER.info("------------------ Inside populateDaywiseTotal--------------");

    new DepartmentwiseExpenditureResult();
    departmentwiseExpList = new ArrayList<DepartmentwiseExpenditureReport>();
    final Query query = deService.getConcurrenceDaywiseTotalQuery(deptReport);
    query.setResultTransformer(Transformers.aliasToBean(DepartmentwiseExpenditureReport.class));
    departmentwiseExpList.addAll(query.list());

    if (LOGGER.isDebugEnabled())
        LOGGER.debug(" Putting concurrene given values to the depratment map  ");

    // adding total to the set

    for (final DepartmentwiseExpenditureReport obj : departmentwiseExpList) {
        new DepartmentwiseExpenditureResult();
        if (deptReport.getPeriod().equalsIgnoreCase("current")) {
            if (deptReport.containsDepartmentInResultList(obj.getDepartmentName(),
                    deptReport.getCurrentyearDepartmentList()))
                for (final DepartmentwiseExpenditureResult entry : deptReport.getCurrentyearDepartmentList())
                    if (obj.getDepartmentName().equalsIgnoreCase(entry.getDepartmentNm())) {
                        // if(LOGGER.isInfoEnabled()) LOGGER.info("@&& Total for -----"+obj.getDepartmentName());
                        entry.getDayAmountMap().put("Total",
                                divideAndRound(obj.getConcurrenceAmount(), BigDecimal.valueOf(100000)));
                        break;
                    }/*from ww  w  .  ja va  2s. com*/
            deptReport.getConcurrenceDateSet().add("Total");
        } else if (deptReport.getPeriod().equalsIgnoreCase("previous")) {
            if (deptReport.containsDepartmentInResultList(obj.getDepartmentName(),
                    deptReport.getPreviousyearDepartmentList()))
                for (final DepartmentwiseExpenditureResult entry : deptReport.getPreviousyearDepartmentList())
                    if (obj.getDepartmentName().equalsIgnoreCase(entry.getDepartmentNm())) {
                        // if(LOGGER.isInfoEnabled()) LOGGER.info("@&& Total for -----"+obj.getDepartmentName());
                        entry.getDayAmountMap().put("Total",
                                divideAndRound(obj.getConcurrenceAmount(), BigDecimal.valueOf(100000)));
                        break;
                    }
            deptReport.getPreviousConcurrenceDateSet().add("Total");
        }
    }
}

From source file:org.egov.egf.web.actions.report.RtgsIssueRegisterReportAction.java

License:Open Source License

@SuppressWarnings("unchecked")
@ValidationErrorPage(NEW)//  w  w  w. ja  v  a 2 s . c om
@ReadOnly
@Action(value = "/report/rtgsIssueRegisterReport-search")
public String search() {
    searchResult = Boolean.TRUE;
    if (LOGGER.isDebugEnabled())
        LOGGER.debug(" Seraching RTGS result for given criteria ");

    final Query query = persistenceService.getSession().createSQLQuery(getQueryString().toString())
            .addScalar("ihId", BigDecimalType.INSTANCE).addScalar("rtgsNumber").addScalar("rtgsDate")
            .addScalar("vhId", BigDecimalType.INSTANCE).addScalar("paymentNumber").addScalar("paymentDate")
            .addScalar("paymentAmount").addScalar("department").addScalar("status").addScalar("bank")
            .addScalar("bankBranch").addScalar("dtId", BigDecimalType.INSTANCE)
            .addScalar("dkId", BigDecimalType.INSTANCE).addScalar("accountNumber");
    if (null == parameters.get("rtgsAssignedFromDate")[0]
            || parameters.get("rtgsAssignedFromDate")[0].equalsIgnoreCase(""))
        query.setDate("finStartDate", new java.sql.Date(fromDate.getTime()));
    if (LOGGER.isInfoEnabled())
        LOGGER.info("Search Query ------------>" + query);

    query.setResultTransformer(Transformers.aliasToBean(BankAdviceReportInfo.class));
    rtgsDisplayList = query.list();
    populateSubLedgerDetails();
    rtgsReportList.addAll(rtgsDisplayList);
    return "search";
}

From source file:org.egov.egf.web.actions.voucher.CommonAction.java

License:Open Source License

@SuppressWarnings("unchecked")
@Action(value = "/voucher/common-ajaxLoadVoucherAmount")
public String ajaxLoadVoucherAmount() {
    final String chequeAmtQry = "select ih.instrumentamount, ih.id from egf_instrumentheader ih, egf_instrumentvoucher"
            + " iv where ih.id= iv.instrumentheaderid and iv.voucherheaderid=?";
    final List<Object[]> resultList2 = persistenceService.getSession().createSQLQuery(chequeAmtQry)
            .setLong(0, billVhId).list();
    String chqAmtResult;//from www  .j av  a2s. c o m
    if (resultList2.size() == 0)
        chqAmtResult = "0$0";
    else
        chqAmtResult = resultList2.get(0)[0] + "$" + resultList2.get(0)[1];
    new CommonBean();
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("Starting ajaxLoadFundingAgencyAmount...");
    if (billVhId != null && billVhId.intValue() != 0) {
        final String grantAMountQry = "select sum(g.debitAmount) as accountBalance from generalledger g"
                + " where g.voucherheaderid=? ";
        // List<Object[]> resultList1=
        final Query qry = persistenceService.getSession().createSQLQuery(grantAMountQry)
                .addScalar("accountBalance", BigDecimalType.INSTANCE);
        qry.setLong(0, billVhId);
        qry.setResultTransformer(Transformers.aliasToBean(CommonBean.class));
        final List<CommonBean> resultList1 = qry.list();
        String grantAmountResult;
        if (resultList1.size() == 0)
            grantAmountResult = "0$0";
        else
            grantAmountResult = resultList1.get(0).getAccountBalance().toString();
        if (resultList2.size() == 0)
            returnStream = grantAmountResult;
        else
            returnStream = chqAmtResult;
    }
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("Completed ajaxLoadFundingAgencyAmount.");
    return "AJAX_RESULT";
}

From source file:org.egov.lcms.transactions.service.SearchLegalCaseService.java

License:Open Source License

private Query setParametersToQuery(final LegalCaseSearchResult legalCaseSearchResultObj,
        final Query queryResult) {
    queryResult.setString("moduleType", LcmsConstants.MODULE_TYPE_LEGALCASE);
    if (StringUtils.isNotBlank(legalCaseSearchResultObj.getLcNumber()))
        queryResult.setString("lcNumber", legalCaseSearchResultObj.getLcNumber());
    if (StringUtils.isNotBlank(legalCaseSearchResultObj.getCaseNumber()))
        queryResult.setString("caseNumber", legalCaseSearchResultObj.getCaseNumber() + "%");
    if (legalCaseSearchResultObj.getCourtId() != null)
        queryResult.setInteger("court", legalCaseSearchResultObj.getCourtId());
    if (legalCaseSearchResultObj.getCasecategory() != null)
        queryResult.setInteger("casetype", legalCaseSearchResultObj.getCasecategory());
    if (legalCaseSearchResultObj.getCourtType() != null)
        queryResult.setInteger("courttype", legalCaseSearchResultObj.getCourtType());
    if (StringUtils.isNotBlank(legalCaseSearchResultObj.getStandingCouncil()))
        queryResult.setString("standingcoouncil", legalCaseSearchResultObj.getStandingCouncil() + "%");
    if (legalCaseSearchResultObj.getStatusId() != null)
        queryResult.setInteger("status", legalCaseSearchResultObj.getStatusId());

    if (legalCaseSearchResultObj.getCaseFromDate() != null)
        queryResult.setDate("fromdate", legalCaseSearchResultObj.getCaseFromDate());
    if (legalCaseSearchResultObj.getCaseToDate() != null)
        queryResult.setDate("toDate", legalCaseSearchResultObj.getCaseToDate());
    if (legalCaseSearchResultObj.getPetitionTypeId() != null)
        queryResult.setInteger("petiontionType", legalCaseSearchResultObj.getPetitionTypeId());
    if (legalCaseSearchResultObj.getReportStatusId() != null)
        queryResult.setInteger("reportStatus", legalCaseSearchResultObj.getReportStatusId());
    if (legalCaseSearchResultObj.getIsStatusExcluded() != null) {
        final List<String> statusCodeList = new ArrayList<>();
        statusCodeList.add(LcmsConstants.LEGALCASE_STATUS_CLOSED);
        statusCodeList.add(LcmsConstants.LEGALCASE_STATUS_JUDGMENT_IMPLIMENTED);
        queryResult.setParameterList("statusCodeList", statusCodeList);
    }//ww w.  jav  a2s.  co  m
    queryResult.setResultTransformer(new AliasToBeanResultTransformer(LegalCaseSearchResult.class));
    return queryResult;
}

From source file:org.egov.ptis.actions.reports.BakayaFeristReportAction.java

License:Open Source License

@SuppressWarnings("unchecked")
private List<AssesseeInfo> prepareAssessees() {
    LOGGER.debug("Entered into prepareAssesseeInformation method");

    List<AssesseeInfo> assessees = new ArrayList<AssesseeInfo>();
    StringBuilder queryBuilder = new StringBuilder(500);

    queryBuilder.append("from PropertyMaterlizeView pmv left join fetch pmv.instDmdColl instDmdColl ")
            .append("left join fetch instDmdColl.installment")
            .append(" where pmv.ward.id = ? and pmv.propTypeMstrID.code not in ('")
            .append(OWNERSHIP_TYPE_CENTRAL_GOVT_50).append("', '").append(OWNERSHIP_TYPE_STATE_GOVT)
            .append("' ) ");
    if (partNo != null && !partNo.equals("-1")) {
        queryBuilder.append("and pmv.partNo = ?");
    }//from   w  w w.j  a  va  2 s  .  c  o  m
    queryBuilder.append(
            "order by to_number(regexp_substr(pmv.houseNo, '" + PATTERN_BEGINS_WITH_1TO9 + "')), pmv.houseNo");
    Query qry = getPersistenceService().getSession().createQuery(queryBuilder.toString());
    qry.setParameter(0, getWardId());
    if (partNo != null && !partNo.equals("-1")) {
        qry.setParameter(1, partNo);
    }
    List<PropertyMaterlizeView> properties = (List<PropertyMaterlizeView>) qry
            .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list();

    Installment currentInstallment = propertyTaxCommonUtils.getCurrentInstallment();

    BigDecimal grandTotal = BigDecimal.ZERO;

    for (PropertyMaterlizeView property : properties) {
        AssesseeInfo assessee = new AssesseeInfo();
        assessee.setIndexNo(property.getPropertyId());
        assessee.setHouseNo(property.getHouseNo());
        assessee.setOwnerName(property.getOwnerName());

        Set<TaxInfo> taxInfos = new TreeSet<TaxInfo>(new Comparator<TaxInfo>() {

            @Override
            public int compare(TaxInfo o1, TaxInfo o2) {
                return o2.getInstallment().compareTo(o1.getInstallment());
            }
        });

        Set<InstDmdCollMaterializeView> demandDetailsAndInstallments = new TreeSet<InstDmdCollMaterializeView>(
                new Comparator<InstDmdCollMaterializeView>() {
                    @Override
                    public int compare(InstDmdCollMaterializeView o1, InstDmdCollMaterializeView o2) {
                        return o1.getInstallment().compareTo(o2.getInstallment());
                    }
                });

        demandDetailsAndInstallments.addAll(property.getInstDmdColl());

        grandTotal = BigDecimal.ZERO;

        for (InstDmdCollMaterializeView demandDetailsAndInstallment : demandDetailsAndInstallments) {
            TaxInfo taxInfo = new TaxInfo();

            /*
             * Installment installment = (Installment)
             * CommonsDaoFactory.getDAOFactory().getInstallmentDao()
             * .findById
             * (demandDetailsAndInstallment.getInstallment().getId(),
             * false);
             */

            /*
             * installmentFromDate.setTime(installment.getFromDate());
             * installmentToDate.setTime(installment.getToDate());
             */

            // taxInfo.setInstallment(installmentFromDate.get(YEAR) + "-" +
            // installmentToDate.get(YEAR));
            // TODO : commented as part of DCB report story.
            /*
             * axInfo.setInstallment(demandDetailsAndInstallment.getInstallment
             * ().toString());
             * taxInfo.setConservancyTax(demandDetailsAndInstallment
             * .getSewerageTax()
             * .subtract(demandDetailsAndInstallment.getSewerageTaxColl())
             * .setScale(2, BigDecimal.ROUND_HALF_UP));
             * taxInfo.setGeneralTax
             * (demandDetailsAndInstallment.getGeneralTax()
             * .subtract(demandDetailsAndInstallment.getGeneralTaxColl())
             * .setScale(2, BigDecimal.ROUND_HALF_UP));
             * taxInfo.setWaterTax(demandDetailsAndInstallment.getWaterTax()
             * .
             * subtract(demandDetailsAndInstallment.getWaterTaxColl()).setScale
             * (2, BigDecimal.ROUND_HALF_UP));
             * taxInfo.setFireServiceTax(demandDetailsAndInstallment
             * .getFireTax()
             * .subtract(demandDetailsAndInstallment.getFireTaxColl
             * ()).setScale(2, BigDecimal.ROUND_HALF_UP));
             * taxInfo.setLightTax(demandDetailsAndInstallment.getLightTax()
             * .
             * subtract(demandDetailsAndInstallment.getLightTaxColl()).setScale
             * (2, BigDecimal.ROUND_HALF_UP));
             * taxInfo.setEduCess(demandDetailsAndInstallment
             * .getEduCessNonResdTax()
             * .add(demandDetailsAndInstallment.getEduCessResdTax())
             * .subtract(
             * demandDetailsAndInstallment.getEduCessNonResdTaxColl().add(
             * demandDetailsAndInstallment.getEduCessResdTaxColl()))
             * .setScale(2, BigDecimal.ROUND_HALF_UP));
             * taxInfo.setEgsCess(demandDetailsAndInstallment.getEgsTax()
             * .subtract
             * (demandDetailsAndInstallment.getEgsTaxColl()).setScale(2,
             * BigDecimal.ROUND_HALF_UP));
             * taxInfo.setBigBuildingCess(demandDetailsAndInstallment
             * .getBigBldgTax()
             * .subtract(demandDetailsAndInstallment.getBigBldgTaxColl())
             * .setScale(2, BigDecimal.ROUND_HALF_UP));
             * taxInfo.setTotal(demandDetailsAndInstallment
             * .getSewerageTax()
             * .subtract(demandDetailsAndInstallment.getSewerageTaxColl())
             * .add(demandDetailsAndInstallment.getGeneralTax().subtract(
             * demandDetailsAndInstallment.getGeneralTaxColl()))
             * .add(demandDetailsAndInstallment.getWaterTax().subtract(
             * demandDetailsAndInstallment.getWaterTaxColl()))
             * .add(demandDetailsAndInstallment.getFireTax().subtract(
             * demandDetailsAndInstallment.getFireTaxColl()))
             * .add(demandDetailsAndInstallment.getLightTax().subtract(
             * demandDetailsAndInstallment.getLightTaxColl()))
             * .add(demandDetailsAndInstallment
             * .getEduCessNonResdTax().subtract(
             * demandDetailsAndInstallment.getEduCessNonResdTaxColl()))
             * .add(
             * demandDetailsAndInstallment.getEduCessResdTax().subtract(
             * demandDetailsAndInstallment.getEduCessResdTaxColl()))
             * .add(demandDetailsAndInstallment.getEgsTax().subtract(
             * demandDetailsAndInstallment.getEgsTaxColl()))
             * .add(demandDetailsAndInstallment.getBigBldgTax().subtract(
             * demandDetailsAndInstallment.getBigBldgTaxColl())).setScale(2,
             * BigDecimal.ROUND_HALF_UP)); grandTotal =
             * grandTotal.add(taxInfo.getTotal());
             */

            if (currentInstallment.equals(demandDetailsAndInstallment.getInstallment())) {
                taxInfo.setGrandTotal(grandTotal.setScale(2, BigDecimal.ROUND_HALF_UP));
            }
            if (taxInfo.getTotal().compareTo(BigDecimal.ZERO.setScale(2)) != 0) {
                taxInfos.add(taxInfo);
            }
        }
        assessee.setTaxInfoList(new ArrayList<TaxInfo>(taxInfos));
        assessees.add(assessee);
    }

    LOGGER.debug("Exit from prepareReportInfo method");

    return assessees;
}

From source file:org.egov.ptis.domain.service.report.ReportService.java

License:Open Source License

@ReadOnly
public List<CurrentInstDCBReportResult> getCurrentInstallmentDCB(final String ward) {
    final StringBuilder queryStr = new StringBuilder(500);

    queryStr.append(/*from   ww  w  .j av  a 2 s .c o m*/
            "select ward.name as \"wardName\", cast(count(*) as integer) as \"noOfProperties\", cast(sum(pi.aggregate_current_firsthalf_demand+pi.aggregate_current_secondhalf_demand) as numeric) as \"currDemand\", cast(sum(pi.current_firsthalf_collection+pi.current_secondhalf_collection) as numeric) as \"currCollection\", cast(sum(pi.aggregate_arrear_demand) as numeric) as \"arrearDemand\",cast(sum(pi.arrearcollection) as numeric) as \"arrearCollection\" from egpt_mv_propertyinfo pi,"
                    + " eg_boundary ward where ward.id = pi.wardid and pi.isexempted = false and pi.isactive=true and ward.boundarytype = (select id from eg_boundary_type where name='Ward' and hierarchytype = (select id from eg_hierarchy_type where name= 'REVENUE')) ");

    if (StringUtils.isNotBlank(ward))
        queryStr.append(" and pi.wardid=:ward ");

    queryStr.append("group by ward.name order by ward.name ");
    final Query query = propPerServ.getSession().createSQLQuery(queryStr.toString());
    if (StringUtils.isNotBlank(ward))
        query.setLong("ward", Long.valueOf(ward));

    query.setResultTransformer(new AliasToBeanResultTransformer(CurrentInstDCBReportResult.class));
    return query.list();
}