Example usage for org.hibernate Query setCharacter

List of usage examples for org.hibernate Query setCharacter

Introduction

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

Prototype

@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setCharacter(String name, char val) 

Source Link

Document

Bind a named char-valued parameter.

Usage

From source file:org.egov.commons.dao.ChartOfAccountsHibernateDAO.java

License:Open Source License

/**
 * This API will return the list of detailed chartofaccounts objects that are active for posting for the Type.
 * /*from ww  w .  ja va2 s . c  o m*/
 * @param -Accounting type-(Asset (A), Liability (L), Income (I), Expense (E))
 * @return list of chartofaccount objects
 */
public List<CChartOfAccounts> getActiveAccountsForType(final char type) {
    final Query query = getCurrentSession().createQuery(
            "select acc from CChartOfAccounts acc where acc.classification='4' and acc.isActiveForPosting=true and type=:type order by acc.name");

    query.setCharacter("type", type);
    return query.list();
}

From source file:org.egov.commons.dao.ChartOfAccountsHibernateDAO.java

License:Open Source License

@Override
public List<CChartOfAccounts> findByType(Character type) {

    final Query query = getCurrentSession()
            .createQuery("from CChartOfAccounts where  " + "type =:type and classification=1");
    query.setCharacter("type", type);
    // query.setCacheable(true);
    return query.list();
}

From source file:org.egov.pims.service.EmployeeServiceImpl.java

License:Open Source License

public boolean checkPos(Integer posId, Date fromDate, Date toDate, Integer empId, String isPrimary) {

    boolean b = false;

    try {/*from ww w. j a  v a  2  s .co m*/
        Query qry = null;

        if (fromDate != null && toDate != null) {
            String main = "from Assignment ev  where ev.isPrimary =:isPrimary and ev.position.id = :posId and ";
            if (empId != null) {
                main += "ev.employee.idPersonalInformation <>:empId and ";
            }
            main += "((ev.toDate is null ) or " + " (ev.fromDate <= :fromDate and ev.toDate >= :toDate) or "
                    + " (ev.toDate <= :toDate and ev.toDate >= :fromDate) or "
                    + " (ev.fromDate >= :fromDate and ev.fromDate <= :toDate))  ";

            qry = getCurrentSession().createQuery(main);

        } else if (fromDate != null && toDate == null) {
            qry = getCurrentSession().createQuery(
                    "from Assignment ev  where ev.position.id = :posId and ((ev.toDate is null ) or (ev.fromDate <= :fromDate AND ev.toDate >= :fromDate))");

        }
        if (posId != null) {
            qry.setInteger("posId", posId);

        }
        if (empId != null) {
            qry.setInteger("empId", empId);

        }
        if (isPrimary != null) {
            qry.setCharacter("isPrimary", Character.valueOf(isPrimary.charAt(0)));
        }
        if (fromDate != null && toDate != null) {
            qry.setDate("fromDate", new java.sql.Date(fromDate.getTime()));
            qry.setDate("toDate", new java.sql.Date(toDate.getTime()));

        } else if (fromDate != null && toDate == null) {
            qry.setDate("fromDate", new java.sql.Date(fromDate.getTime()));
        }

        if (qry.list() != null && !qry.list().isEmpty()) {
            b = true;
        }

    } catch (HibernateException he) {
        LOGGER.error(he);
        throw new ApplicationRuntimeException("Exception:" + he.getMessage(), he);
    } catch (Exception he) {
        LOGGER.error(he);
        throw new ApplicationRuntimeException("Exception:" + he.getMessage(), he);

    }
    return b;

}