Example usage for org.hibernate.type LongType INSTANCE

List of usage examples for org.hibernate.type LongType INSTANCE

Introduction

In this page you can find the example usage for org.hibernate.type LongType INSTANCE.

Prototype

LongType INSTANCE

To view the source code for org.hibernate.type LongType INSTANCE.

Click Source Link

Usage

From source file:net.e6tech.elements.persist.hibernate.ModifiedTableGenerator.java

License:Apache License

@Override
public void registerExportables(Database database) {
    final Dialect dialect = database.getJdbcEnvironment().getDialect();

    final Namespace namespace = database.locateNamespace(qualifiedTableName.getCatalogName(),
            qualifiedTableName.getSchemaName());

    Table table = namespace.locateTable(qualifiedTableName.getObjectName());
    if (table == null) {
        table = namespace.createTable(qualifiedTableName.getObjectName(), false);

        // todo : note sure the best solution here.  do we add the columns if missing?  other?
        final Column segmentColumn = new ExportableColumn(database, table, segmentColumnName,
                StringType.INSTANCE, dialect.getTypeName(Types.VARCHAR, segmentValueLength, 0, 0));
        segmentColumn.setNullable(false);
        table.addColumn(segmentColumn);/*  ww  w. j av  a2 s .  c  o  m*/

        // lol
        table.setPrimaryKey(new PrimaryKey(table));
        table.getPrimaryKey().addColumn(segmentColumn);

        final Column valueColumn = new ExportableColumn(database, table, valueColumnName, LongType.INSTANCE);
        table.addColumn(valueColumn);
    }

    // allow physical naming strategies a chance to kick in
    this.renderedTableName = database.getJdbcEnvironment().getQualifiedObjectNameFormatter()
            .format(table.getQualifiedTableName(), dialect);

    this.selectQuery = buildSelectQuery(dialect);
    this.updateQuery = buildUpdateQuery();
    this.insertQuery = buildInsertQuery();

}

From source file:net.sf.beanlib.hibernate4.Hibernate4SequenceGenerator.java

License:Apache License

/** Returns the identifier generator created for the specified sequence and session. */
private static IdentifierGenerator createIdentifierGenerator(String sequenceName, Session session) {
    SessionFactory sessionFactory = session.getSessionFactory();

    if (!(sessionFactory instanceof SessionFactoryImpl)) {
        throw new IllegalStateException("Not yet know how to handle the session factory of the given session!");
    }//from  ww  w  .j  ava 2 s.  c o m
    SessionFactoryImpl sessionFactoryImpl = (SessionFactoryImpl) sessionFactory;
    //        Dialect dialect = sessionFactoryImpl.getDialect();
    ServiceRegistry registry = sessionFactoryImpl.getServiceRegistry();

    Properties params = new Properties();
    params.setProperty("sequence", sequenceName);

    SequenceStyleGenerator sequenceStyleGenerator = new SequenceStyleGenerator();
    sequenceStyleGenerator.configure(LongType.INSTANCE, params, (ServiceRegistry) registry);

    //        SequenceGenerator sequenceGenerator = new SequenceGenerator();
    //        sequenceGenerator.configure(LongType.INSTANCE, params, dialect);

    return sequenceStyleGenerator;
}

From source file:org.babyfish.hibernate.cfg.Configuration.java

License:Open Source License

@SuppressWarnings("unchecked")
private void addNativeFunctions() {
    Map<String, SQLFunction> map = this.getSqlFunctions();

    map.put("nativeInteger", new AbstractNativeFunction() {
        @Override//from w w w  .  ja  va  2  s .c  o m
        public Type getReturnType(Type firstArgumentType, Mapping mapping) throws QueryException {
            return IntegerType.INSTANCE;
        }
    });
    map.put("nativeLong", new AbstractNativeFunction() {
        @Override
        public Type getReturnType(Type firstArgumentType, Mapping mapping) throws QueryException {
            return LongType.INSTANCE;
        }
    });
    map.put("nativeFloat", new AbstractNativeFunction() {
        @Override
        public Type getReturnType(Type firstArgumentType, Mapping mapping) throws QueryException {
            return FloatType.INSTANCE;
        }
    });
    map.put("nativeDouble", new AbstractNativeFunction() {
        @Override
        public Type getReturnType(Type firstArgumentType, Mapping mapping) throws QueryException {
            return DoubleType.INSTANCE;
        }
    });
    map.put("nativeBigInteger", new AbstractNativeFunction() {
        @Override
        public Type getReturnType(Type firstArgumentType, Mapping mapping) throws QueryException {
            return BigIntegerType.INSTANCE;
        }
    });
    map.put("nativeBigDecimal", new AbstractNativeFunction() {
        @Override
        public Type getReturnType(Type firstArgumentType, Mapping mapping) throws QueryException {
            return BigDecimalType.INSTANCE;
        }
    });
    map.put("nativeString", new AbstractNativeFunction() {
        @Override
        public Type getReturnType(Type firstArgumentType, Mapping mapping) throws QueryException {
            return StringType.INSTANCE;
        }
    });
    //TODO: more types, all the derived types of org.hibernate.type.AbstractSingleColumnStandardBasicType
}

From source file:org.babyfish.test.hibernate.model.delay.BagAndReferenceTest.java

License:Open Source License

private void init(final boolean hasRelationship) {
    Action<Session> handler = new Action<Session>() {
        @Override//from   w w w.  ja  v a2s.c  om
        public void run(Session session) {
            session.createSQLQuery("DELETE FROM br_EMPLOYEE").executeUpdate();
            session.createSQLQuery("DELETE FROM br_DEPARTMENT").executeUpdate();
            session.createSQLQuery("INSERT INTO br_DEPARTMENT(DEPARTMENT_ID, NAME) VALUES(?, ?)").setLong(0, 1L)
                    .setString(1, "department").executeUpdate();
            Query query = session
                    .createSQLQuery("INSERT INTO br_EMPLOYEE(EMPLOYEE_ID, NAME, DEPARTMENT_ID) VALUES(?, ?, ?)")
                    .setLong(0, 1L).setString(1, "employee");
            if (hasRelationship) {
                query.setLong(2, 1L);
            } else {
                query.setParameter(2, null, LongType.INSTANCE);
            }
            query.executeUpdate();
        }
    };
    execute(handler);
}

From source file:org.babyfish.test.hibernate.model.delay.SetAndReferenceTest.java

License:Open Source License

private void init(final boolean hasRelationship) {
    Action<Session> handler = new Action<Session>() {
        @Override/*from w w w  . j a  v  a 2  s. c  om*/
        public void run(Session session) {
            session.createSQLQuery("DELETE FROM sr_EMPLOYEE").executeUpdate();
            session.createSQLQuery("DELETE FROM sr_DEPARTMENT").executeUpdate();
            session.createSQLQuery("INSERT INTO sr_DEPARTMENT(DEPARTMENT_ID, NAME) VALUES(?, ?)").setLong(0, 1L)
                    .setString(1, "department").executeUpdate();
            Query query = session
                    .createSQLQuery("INSERT INTO sr_EMPLOYEE(EMPLOYEE_ID, NAME, DEPARTMENT_ID) VALUES(?, ?, ?)")
                    .setLong(0, 1L).setString(1, "employee");
            if (hasRelationship) {
                query.setLong(2, 1L);
            } else {
                query.setParameter(2, null, LongType.INSTANCE);
            }
            query.executeUpdate();
        }
    };
    execute(handler);
}

From source file:org.bonitasoft.engine.persistence.SQLQueryBuilder.java

License:Open Source License

private void setReturnType(String builtQuery, SQLQuery sqlQuery) {
    if (isCountQuery(builtQuery)) {
        sqlQuery.addScalar("count", LongType.INSTANCE);
    } else {/*  w  ww . ja  v  a 2 s  .c om*/
        String hqlAlias = classAliasMappings.get(entityType.getName());
        String sqlAlias = hqlToSqlAlias.containsKey(hqlAlias) ? hqlAlias.replace("user", "user_") : hqlAlias;
        Class<? extends PersistentObject> entityClass = interfaceToClassMapping.get(entityType.getName());
        sqlQuery.addEntity(sqlAlias, entityClass.getName());
    }
}

From source file:org.cms.dao.VestDao.java

@Transactional
public Statistika[] vratiParametreZaStatistiku() {
    Session session = this.sessionFactory.getCurrentSession();
    String upit = "SELECT kategorija.naziv as naziv,COUNT(vest.kategorija) AS brojClanaka FROM vest "
            + "LEFT JOIN kategorija ON vest.kategorija=kategorija.kategorijaID GROUP BY kategorija";
    List<Object[]> redovi = session.createSQLQuery(upit).addScalar("naziv", StringType.INSTANCE)
            .addScalar("brojClanaka", LongType.INSTANCE).list();
    Statistika[] statistike = new Statistika[redovi.size()];
    for (int i = 0; i < redovi.size(); i++) {
        Statistika s = new Statistika((String) redovi.get(i)[0], (Long) redovi.get(i)[1]);
        statistike[i] = s;//from   ww w.  j a  va2 s  .c  o  m
    }
    //        for (Statistika s : lista) {
    //            System.out.println(s.getNazivKategorije() +" :"+s.getBrojVestiPoKategoriji());
    //        }
    return statistike;
}

From source file:org.egov.egf.web.actions.brs.AutoReconcileHelper.java

License:Open Source License

private List<AutoReconcileBean> getStatmentsForProcessing(final String type) {
    final SQLQuery detailQuery = persistenceService.getSession()
            .createSQLQuery("select id,txDate,instrumentNo,debit,credit,CSLno  from " + TABLENAME
                    + " where accountId=:accountId  and type='" + type + "' and action='"
                    + BRS_ACTION_TO_BE_PROCESSED + "'");
    detailQuery.setLong("accountId", accountId);
    detailQuery.addScalar("id", LongType.INSTANCE).addScalar("txDate").addScalar("instrumentNo")
            .addScalar("debit").addScalar("credit").addScalar("CSLno")
            .setResultTransformer(Transformers.aliasToBean(AutoReconcileBean.class));
    final List<AutoReconcileBean> detailList = detailQuery.list();
    return detailList;
}

From source file:org.egov.egf.web.actions.brs.AutoReconcileHelper.java

License:Open Source License

@Action(value = "/brs/autoReconciliation-generateReport")
@SuppressWarnings({ "unchecked", "deprecation" })
@Transactional(readOnly = true)/*from  w  w  w  . j  av  a2 s.  c om*/
public String generateReport() {
    // bankStatments not in BankBook

    try {
        bankBookBalance = eGovernCommon.getAccountBalance(dateFormatter.format(toDate), accountId.toString())
                .setScale(2, BigDecimal.ROUND_HALF_UP);
    } catch (final HibernateException e) {
        throw new ApplicationRuntimeException(e.getMessage());
    } catch (final TaskFailedException e) {
        throw new ApplicationRuntimeException(e.getMessage());
    }
    bankAccount = (Bankaccount) persistenceService.find("from Bankaccount ba where id=?",
            Long.valueOf(accountId));
    final String statmentsNotInBankBookStr = "select id,txDate,instrumentNo,debit,credit,narration,type,action as \"errorCode\",errorMessage from "
            + TABLENAME + " where accountId=:accountId and txdate>=:fromDate "
            + " and txdate<=:toDate and reconciliationdate is null and (errorMesSage is null or errorMessage !=:multipleEntryErrorMessage)"
            + " order by  txDate ";
    final Query statmentsNotInBankBookQry = persistenceService.getSession()
            .createSQLQuery(statmentsNotInBankBookStr).addScalar("instrumentNo").addScalar("credit")
            .addScalar("debit").addScalar("txDate").addScalar("id", LongType.INSTANCE).addScalar("narration")
            .addScalar("type").addScalar("errorCode").addScalar("errorMessage")
            .setResultTransformer(Transformers.aliasToBean(AutoReconcileBean.class));

    statmentsNotInBankBookQry.setDate("fromDate", fromDate).setDate("toDate", toDate)
            .setString("multipleEntryErrorMessage", BRS_MESSAGE_MORE_THAN_ONE_MATCH)
            .setLong("accountId", accountId);
    statementsNotInBankBookList = statmentsNotInBankBookQry.list();
    notInBooktotalDebit = BigDecimal.ZERO;
    notInBooktotalCredit = BigDecimal.ZERO;
    notInBookNet = BigDecimal.ZERO;

    for (final AutoReconcileBean ab : statementsNotInBankBookList) {
        notInBooktotalDebit = notInBooktotalDebit.add(ab.getDebit() == null ? BigDecimal.ZERO : ab.getDebit());
        notInBooktotalCredit = notInBooktotalCredit
                .add(ab.getCredit() == null ? BigDecimal.ZERO : ab.getCredit());
    }
    notInBookNet = notInBooktotalCredit.subtract(notInBooktotalDebit);
    if (notInBookNet.compareTo(BigDecimal.ZERO) == -1)
        notInBookNetBal = notInBookNet + "(Dr)";
    else
        notInBookNetBal = notInBookNet + "(Cr)";
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("notInBookNet" + notInBookNet);

    final CFinancialYear finYearByDate = financialYearDAO.getFinYearByDate(toDate);
    finYearStartDate = finYearByDate.getStartingDate();

    String entriesNotInBankStamentStr = "select  instrumentnumber as \"instrumentNo\","
            + " instrumentdate as \"txDate\", instrumentamount as \"credit\",null as \"debit\", payto as \"narration\"  from egf_instrumentheader  where bankaccountid=:accountId and instrumentdate BETWEEN"
            + " :fromDate and :toDate and ispaycheque='0' and id_status=(select id from egw_status where moduletype='Instrument'  and description='Deposited')"
            + " and instrumentnumber is not null and instrumentamount is not null and instrumentnumber||'-'||instrumentamount not in (select  instrumentno||'-'|| credit from egf_brs_bankstatements "
            + " where accountid=:accountId and txdate between :fromDate and :toDate and action=:action and errorMessage =:multipleEntryErrorMessage  and instrumentno is not null and  credit is not null and credit>0) "
            + " union " + " select   instrumentnumber as \"instrumentNo\","
            + " instrumentdate as \"txDate\", instrumentamount \"debit\",null as \"credit\", payto as \"narration\" "
            + " from egf_instrumentheader where bankaccountid=:accountId and instrumentdate BETWEEN :fromDate and :toDate "
            + " and ispaycheque='1' and id_status=(select id from egw_status where moduletype='Instrument'  and description='New')"
            + " and  instrumentnumber is not null   and instrumentamount is not null and instrumentnumber||'-'||instrumentamount not in  (select  instrumentno||'-'|| debit from egf_brs_bankstatements"
            + " where accountid=:accountId and txdate between :fromDate and :toDate and action=:action and errorMessage =:multipleEntryErrorMessage  and instrumentno is not null and debit is not null and debit>0) order by \"txDate\"";
    Query entriesNotInBankStamentQry = persistenceService.getSession()
            .createSQLQuery(entriesNotInBankStamentStr).addScalar("instrumentNo").addScalar("credit")
            .addScalar("debit").addScalar("txDate").addScalar("narration")
            .setResultTransformer(Transformers.aliasToBean(AutoReconcileBean.class));

    entriesNotInBankStamentQry.setDate("fromDate", finYearStartDate).setDate("toDate", toDate)
            .setString("action", BRS_ACTION_TO_BE_PROCESSED_MANUALLY).setLong("accountId", accountId)
            .setString("multipleEntryErrorMessage", BRS_MESSAGE_MORE_THAN_ONE_MATCH);
    entriesNotInBankStament = entriesNotInBankStamentQry.list();

    /**
     * ---------------------------------------
     */

    notInStatementTotalDebit = BigDecimal.ZERO;
    notInStatementTotalCredit = BigDecimal.ZERO;
    notInStatementNet = BigDecimal.ZERO;
    for (final AutoReconcileBean ab : entriesNotInBankStament) {
        // LOGGER.error("notInStatementTotalDebit=="+notInStatementTotalDebit+"           "+ab.getDebit());
        notInStatementTotalDebit = notInStatementTotalDebit
                .add(ab.getDebit() == null ? BigDecimal.ZERO : ab.getDebit());
        LOGGER.error(
                "no=" + ab.getInstrumentNo() + " t =" + notInStatementTotalCredit + " a=" + ab.getCredit());
        notInStatementTotalCredit = notInStatementTotalCredit
                .add(ab.getCredit() == null ? BigDecimal.ZERO : ab.getCredit());
        // LOGGER.error("notInStatementTotalCredit=="+notInStatementTotalCredit+"           "+"notInStatementTotalDebit=="+notInStatementTotalDebit+"           count"+i);
    }
    LOGGER.error("notInStatementTotalCredit==" + notInStatementTotalCredit + "           "
            + "notInStatementTotalDebit==" + notInStatementTotalDebit);
    notInStatementNet = notInStatementTotalCredit.subtract(notInStatementTotalDebit);// this one will be reverse
    // LOGGER.error("notInStatementTotalCredit=="+notInStatementTotalCredit+"           "+"notInStatementTotalDebit=="+notInStatementTotalDebit
    // +"notInStatementNet                       "+notInStatementNet);
    // for match

    entriesNotInBankStamentStr = "select  sum(instrumentamount) as \"credit\"  from egf_instrumentheader  where bankaccountid=:accountId and instrumentdate BETWEEN"
            + " :fromDate and :toDate and ispaycheque='0' and id_status=(select id from egw_status where moduletype='Instrument'  and description='Deposited')"
            + " and instrumentnumber is not null and instrumentamount is not null and instrumentnumber||'-'||instrumentamount not in (select  instrumentno||'-'|| credit from egf_brs_bankstatements "
            + " where accountid=:accountId and txdate between :fromDate and :toDate and action=:action and errorMessage =:multipleEntryErrorMessage  and instrumentno is not null and  credit is not null and credit>0) "
            + " union " + " select   sum(instrumentamount) as \"credit\" "
            + " from egf_instrumentheader where bankaccountid=:accountId and instrumentdate BETWEEN :fromDate and :toDate "
            + " and ispaycheque='1' and id_status=(select id from egw_status where moduletype='Instrument'  and description='New')"
            + " and  instrumentnumber is not null   and instrumentamount is not null and instrumentnumber||'-'||instrumentamount not in  (select  instrumentno||'-'|| debit from egf_brs_bankstatements"
            + " where accountid=:accountId and txdate between :fromDate and :toDate and action=:action and errorMessage =:multipleEntryErrorMessage  and instrumentno is not null and debit is not null and debit>0) ";
    entriesNotInBankStamentQry = persistenceService.getSession().createSQLQuery(entriesNotInBankStamentStr)
            // .addScalar("instrumentNo")
            .addScalar("credit")
            // .addScalar("debit")
            // .addScalar("txDate")
            // .addScalar("narration")
            .setResultTransformer(Transformers.aliasToBean(AutoReconcileBean.class));

    entriesNotInBankStamentQry.setDate("fromDate", finYearStartDate).setDate("toDate", toDate)
            .setString("action", BRS_ACTION_TO_BE_PROCESSED_MANUALLY).setLong("accountId", accountId)
            .setString("multipleEntryErrorMessage", BRS_MESSAGE_MORE_THAN_ONE_MATCH);
    final List<AutoReconcileBean> entriesNotInBankStament1 = entriesNotInBankStamentQry.list();
    if (entriesNotInBankStament1.size() > 0) {
        notInStatementTotalCredit = entriesNotInBankStament1.get(0).getCredit();
        if (notInStatementTotalCredit == null)
            notInStatementTotalCredit = BigDecimal.ZERO;
    }
    if (entriesNotInBankStament1.size() > 1) {
        notInStatementTotalDebit = entriesNotInBankStament1.get(1).getCredit();
        if (notInStatementTotalDebit == null)
            notInStatementTotalDebit = BigDecimal.ZERO;
    }

    notInStatementNet = notInStatementTotalCredit.subtract(notInStatementTotalDebit);

    final String statmentsfoundButNotProcessed = "select id,txDate,instrumentNo,debit,credit,narration,type,action as \"errorCode\",errorMessage "
            + "from " + TABLENAME
            + " where accountId=:accountId and txdate>=:fromDate  and txdate<=:toDate and reconciliationdate is null "
            + " and  errorMessage =:multipleEntryErrorMessage order by  txDate ";
    final Query statmentsfoundButNotProcessedQry = persistenceService.getSession()
            .createSQLQuery(statmentsfoundButNotProcessed).addScalar("instrumentNo").addScalar("credit")
            .addScalar("debit").addScalar("txDate").addScalar("id", LongType.INSTANCE).addScalar("narration")
            .addScalar("type").addScalar("errorCode").addScalar("errorMessage")
            .setResultTransformer(Transformers.aliasToBean(AutoReconcileBean.class));

    statmentsfoundButNotProcessedQry.setDate("fromDate", fromDate).setDate("toDate", toDate)
            .setString("multipleEntryErrorMessage", BRS_MESSAGE_MORE_THAN_ONE_MATCH)
            .setLong("accountId", accountId);
    statementsFoundButNotProcessed = statmentsfoundButNotProcessedQry.list();
    notprocessedDebit = BigDecimal.ZERO;
    notprocessedCredit = BigDecimal.ZERO;
    notprocessedNet = BigDecimal.ZERO;

    for (final AutoReconcileBean ab : statementsFoundButNotProcessed) {
        LOGGER.error("notprocessedDebit==" + notprocessedDebit + "           " + ab.getDebit());
        notprocessedDebit = notprocessedDebit.add(ab.getDebit() == null ? BigDecimal.ZERO : ab.getDebit());
        LOGGER.error("notprocessedCredit==" + notprocessedCredit + "           " + ab.getCredit());
        notprocessedCredit = notprocessedCredit.add(ab.getCredit() == null ? BigDecimal.ZERO : ab.getCredit());
        LOGGER.error("notprocessedDebit==" + notprocessedDebit + "           " + "notprocessedCredit=="
                + notprocessedCredit);
    }
    LOGGER.error("notprocessedDebit==" + notprocessedDebit + "           " + "notprocessedCredit=="
            + notprocessedCredit);
    notprocessedNet = notprocessedCredit.subtract(notprocessedDebit);// this one will be reverse
    LOGGER.error("notprocessedDebit==" + notprocessedDebit + "           " + "notprocessedCredit=="
            + notprocessedCredit);
    totalNotReconciledAmount = notInStatementNet.add(notprocessedNet.negate());
    brsBalance = bankBookBalance.add(notInStatementNet).add(notInBookNet).add(notprocessedNet);
    return "report";

}

From source file:org.egov.egf.web.actions.brs.AutoReconcileHelper.java

License:Open Source License

private void findandUpdateDuplicates() {
    // for payment cheques instrumentNo,debit,accountId combination should be unique else mark it duplicate
    try {//from w ww  .  ja  va2s  . c o m
        String duplicates = "select instrumentNo,debit,accountId from " + TABLENAME
                + " where accountId=:accountId" + " and debit>0 and action='" + BRS_ACTION_TO_BE_PROCESSED
                + "'  group by  instrumentNo,debit,accountId having count(*)>1";
        final SQLQuery paymentDuplicateChequesQuery = persistenceService.getSession()
                .createSQLQuery(duplicates);
        paymentDuplicateChequesQuery.addScalar("instrumentNo").addScalar("debit")
                .addScalar("accountId", LongType.INSTANCE)
                .setResultTransformer(Transformers.aliasToBean(AutoReconcileBean.class));
        // paymentDuplicateChequesQuery.setParameter("accountId", Long.class);
        paymentDuplicateChequesQuery.setLong("accountId", accountId);
        final List<AutoReconcileBean> duplicatePaymentCheques = paymentDuplicateChequesQuery.list();

        final String backUpdateDuplicatePaymentquery = "update " + TABLENAME + " set action='"
                + BRS_ACTION_TO_BE_PROCESSED_MANUALLY + "'," + " errorMessage='"
                + BRS_MESSAGE_DUPPLICATE_IN_BANKSTATEMENT
                + "' where debit=:debit and accountid=:accountId and instrumentNo=:instrumentNo "
                + " and action='" + BRS_ACTION_TO_BE_PROCESSED + "'";

        final SQLQuery paymentDuplicateUpdate = persistenceService.getSession()
                .createSQLQuery(backUpdateDuplicatePaymentquery);
        for (final AutoReconcileBean bean : duplicatePaymentCheques) {

            paymentDuplicateUpdate.setLong("accountId", bean.getAccountId());
            paymentDuplicateUpdate.setBigDecimal("debit", bean.getDebit());
            paymentDuplicateUpdate.setString("instrumentNo", bean.getInstrumentNo());
            paymentDuplicateUpdate.executeUpdate();

        }
        // this portion is for receipts instrumentNo,credit,accountId combination should be unique else mark it duplicate
        duplicates = "select instrumentNo,credit,accountId from " + TABLENAME + " where accountid=:accountId"
                + " and  credit>0 and action='" + BRS_ACTION_TO_BE_PROCESSED
                + "' group by  instrumentNo,credit,accountId having count(*)>1";
        final SQLQuery receiptsDuplicateChequesQuery = persistenceService.getSession()
                .createSQLQuery(duplicates);
        receiptsDuplicateChequesQuery.addScalar("instrumentNo").addScalar("credit")
                .addScalar("accountId", LongType.INSTANCE)
                .setResultTransformer(Transformers.aliasToBean(AutoReconcileBean.class));
        receiptsDuplicateChequesQuery.setLong("accountId", accountId);
        final List<AutoReconcileBean> duplicateReceiptsCheques = receiptsDuplicateChequesQuery.list();

        final String backUpdateDuplicateReceiptsQuery = "update " + TABLENAME + " set action='"
                + BRS_ACTION_TO_BE_PROCESSED_MANUALLY + "'" + " ,errorMessage='"
                + BRS_MESSAGE_DUPPLICATE_IN_BANKSTATEMENT
                + "' where credit=:credit and accountid=:accountId and instrumentNo=:instrumentNo "
                + " and action='" + BRS_ACTION_TO_BE_PROCESSED + "'";
        final SQLQuery receiptDuplicateUpdate = persistenceService.getSession()
                .createSQLQuery(backUpdateDuplicateReceiptsQuery);

        for (final AutoReconcileBean bean : duplicateReceiptsCheques) {
            receiptDuplicateUpdate.setLong("accountId", bean.getAccountId());
            receiptDuplicateUpdate.setBigDecimal("credit", bean.getCredit());
            receiptDuplicateUpdate.setString("instrumentNo", bean.getInstrumentNo());
            receiptDuplicateUpdate.executeUpdate();
        }
    } catch (final HibernateException e) {
        throw new ApplicationRuntimeException("Failed while processing autoreconciliation ");
    }

}