Example usage for org.hibernate SQLQuery setResultTransformer

List of usage examples for org.hibernate SQLQuery setResultTransformer

Introduction

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

Prototype

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

Source Link

Document

Set a strategy for handling the query results.

Usage

From source file:pe.gob.onpe.rae.dao.hibernate.ExpedientePadronDAOH.java

@Override
public List<ExpedientePadron> listarElectores(ExpedientePadron listaPadron, int iOrdenMayorQue) {
    String sql = "SELECT * FROM TAB_EXPEDIENTE_PADRON WHERE N_EXPEDIENTE = :lista AND N_INDICADOR = :indicador AND N_ESTADO NOT IN(:P_ELIMINADO,:P_RECHAZADO) AND N_ORDEN_REGISTRO>:ORDEN ORDER BY N_ORDEN_REGISTRO";
    SQLQuery query = this.getSession().createSQLQuery(sql);
    query.setParameter("lista", listaPadron.getExpediente().getId());
    query.setParameter("indicador", listaPadron.getIndicador());
    query.setParameter("P_ELIMINADO", Parametros.ESTADO_ELECTOR_ELIMINADO);
    query.setParameter("P_RECHAZADO", Parametros.ESTADO_ELECTOR_RECHAZADO);
    query.setParameter("ORDEN", iOrdenMayorQue);
    query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
    List<ExpedientePadron> list = query.list();
    return list;//from   ww w  .  j  av  a2 s.c  o  m
}

From source file:pe.gob.onpe.rae.dao.hibernate.ExpedientePadronDAOH.java

@Override
public List<ExpedientePadron> exportarExpediente(int id) {
    String sql = "SELECT N_ORDEN_REGISTRO, N_EXPEDIENTE, N_AMBITO, C_UBIGEO_ELECTOR, C_DOCUMENTO_IDENTIDAD, C_APELLIDO_PATERNO, C_APELLIDO_MATERNO, C_NOMBRE, N_ESTADO FROM TAB_EXPEDIENTE_PADRON WHERE N_EXPEDIENTE = :lista ORDER BY N_ORDEN_REGISTRO";
    SQLQuery query = this.getSession().createSQLQuery(sql);
    query.setParameter("lista", id);
    query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
    List<ExpedientePadron> list = query.list();
    return list;/*from w w  w.ja  v  a  2  s  . c  om*/
}

From source file:pe.gob.onpe.rae.dao.hibernate.ExpedientePadronDAOH.java

@Override
public List<ExpedientePadron> fetchByExpediente(int codExpediente) {
    String sql = "SELECT * FROM TAB_EXPEDIENTE_PADRON WHERE N_EXPEDIENTE = :N_EXPEDIENTE AND N_ESTADO NOT IN(:P_ELIMINADO,:P_RECHAZADO) ORDER BY N_EXPEDIENTE_PADRON_PK DESC";
    SQLQuery query = this.getSession().createSQLQuery(sql);
    query.setParameter("N_EXPEDIENTE", codExpediente);
    //query.setParameter("P_OTRA_LISTA", Parametros.ESTADO_ELECTOR_REG_OTRA_LISTA);
    query.setParameter("P_ELIMINADO", Parametros.ESTADO_ELECTOR_ELIMINADO);
    query.setParameter("P_RECHAZADO", Parametros.ESTADO_ELECTOR_RECHAZADO);
    query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
    List<ExpedientePadron> list = query.list();
    return list;/* w ww  . j av a  2s.  c  o  m*/
}

From source file:pe.gob.onpe.rae.dao.hibernate.UbigeoDAOH.java

@Override
public List<Ubigeo> fetchDepartamentos() {
    String sql = "SELECT * FROM UBIGEO WHERE UBIPADRE = '000000' AND UBIGEO != '000000' AND UBIGEO NOT LIKE '9%' ORDER BY DESCRIPCION";
    SQLQuery query = this.getSession().createSQLQuery(sql);
    query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
    List<Ubigeo> lstUbigeo = query.list();
    return lstUbigeo;

}

From source file:pe.gob.onpe.rae.dao.hibernate.UbigeoDAOH.java

@Override
public ArrayList allDepartamento() {
    String sql = " SELECT DISTINCT RPAD(SUBSTR(C_UBIGEO_PK,1,2),6,'0') AS codigo, C_DEPARTAMENTO AS descripcion"
            + " FROM VW_UBIGEO" + " ORDER BY 2";
    SQLQuery query = this.getSession().createSQLQuery(sql);
    query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
    ArrayList list = new ArrayList(query.list());
    return list;//from ww w .  j  a v a  2  s.c  o m
}

From source file:pe.gob.onpe.rae.dao.hibernate.UbigeoDAOH.java

@Override
public ArrayList getProvincia(String dep) {
    String sql = " SELECT DISTINCT RPAD(SUBSTR(C_UBIGEO_PK,1,4),6,'0') AS codigo, RPAD(SUBSTR(C_UBIGEO_PK,1,2),6,'0') AS padre, c_provincia AS descripcion"
            + " FROM VW_UBIGEO" + " WHERE RPAD(SUBSTR(C_UBIGEO_PK,1,2),6,'0') = :dep" + " ORDER BY 2";
    SQLQuery query = this.getSession().createSQLQuery(sql);
    query.setParameter("dep", dep);
    query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
    ArrayList list = new ArrayList(query.list());
    return list;//from   w  w w  .j ava 2s.  c o  m
}

From source file:pe.gob.onpe.rae.dao.hibernate.UbigeoDAOH.java

@Override
public ArrayList getDistrito(String prov) {
    String sql = " SELECT DISTINCT c_ubigeo_pk AS codigo, RPAD(SUBSTR(c_ubigeo_pk,1,4),6,'0') AS padre, c_distrito AS descripcion"
            + " FROM VW_UBIGEO" + " WHERE RPAD(SUBSTR(C_UBIGEO_PK,1,4),6,'0') = :prov" + " ORDER BY 2";
    SQLQuery query = this.getSession().createSQLQuery(sql);
    query.setParameter("prov", prov);
    query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
    ArrayList list = new ArrayList(query.list());
    return list;/* w  w w  .j  a  va  2s  .c o  m*/
}

From source file:pkg.NativeSqlProductCode.java

public void listEmployeesScalar() {
    Session session = sessionFactory.openSession();
    Transaction tx = null;/*from   w w  w. j a v a2 s  .  c o  m*/
    try {
        tx = session.beginTransaction();
        String sql = "SELECT first_name, salary FROM EMPLOYEE";
        SQLQuery query = session.createSQLQuery(sql);
        query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
        List data = query.list();

        for (Object object : data) {
            Map row = (Map) object;
            System.out.print("First Name: " + row.get("first_name"));
            System.out.println(", Salary: " + row.get("salary"));
        }
        tx.commit();
    } catch (HibernateException e) {
        if (tx != null) {
            tx.rollback();
        }
        e.printStackTrace();
    } finally {
        session.close();
    }
}

From source file:service.MasterPosisiService.java

public static List<TrJabatan> getDataPosisi() {
    Session session = HibernateUtil.openSession();
    String nativeSql = " select a.jabatan" + " from tr_jabatan a;";
    SQLQuery query = session.createSQLQuery(nativeSql);
    query.setResultTransformer(CriteriaSpecification.ALIAS_TO_ENTITY_MAP);
    List result = query.list();/*from ww w . j  a  v a2s . co m*/
    session.getTransaction().commit();

    List<TrJabatan> returnList = new ArrayList<TrJabatan>();
    for (Object obj : result) {
        Map row = (Map) obj;
        TrJabatan everyRow = new TrJabatan();
        everyRow.setJabatan((String) row.get("JABATAN"));

        returnList.add(everyRow);
    }
    return returnList;

}

From source file:service.MasterWilayahService.java

public static List<TrCabang> getDataCabang() {
    Session session = HibernateUtil.openSession();
    String nativeSql = " select a.nama_cabang" + " from tr_cabang a;";
    SQLQuery query = session.createSQLQuery(nativeSql);
    query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
    List result = query.list();/* w w w. j  av  a  2  s.  co  m*/
    session.getTransaction().commit();

    List<TrCabang> returnList = new ArrayList<TrCabang>();
    for (Object obj : result) {
        Map row = (Map) obj;
        TrCabang everyRow = new TrCabang();

        everyRow.setNamaCabang((String) row.get("NAMA_CABANG"));

        returnList.add(everyRow);
    }
    return returnList;

}