Example usage for org.hibernate SQLQuery list

List of usage examples for org.hibernate SQLQuery list

Introduction

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

Prototype

List<R> list();

Source Link

Document

Return the query results as a List.

Usage

From source file:com.scopix.periscope.extractionservicesserversmanagement.dao.EvidenceExtractionServicesServerDAO.java

License:Open Source License

public List<Integer> getRemoteEvidenceRequestIdList(List<Integer> ids) {
    List<Integer> ers = null;
    StringBuilder sql = new StringBuilder();
    sql.append(/*  w ww .j a v a2s  . c  om*/
            "select business_services_request_id from evidence_request where extraction_plan_detail_id in (");
    sql.append(StringUtils.join(ids, ","));
    sql.append(")");
    //        for (Integer id : ids) {
    //            sql += id + ", ";
    //        }
    //sql = sql.substring(0, sql.length() - 2) + ")";
    SQLQuery query = this.getSession().createSQLQuery(sql.toString());
    ers = query.list();
    this.getSession().flush();
    return ers;
}

From source file:com.se.common.CommonFunctions.java

public static ArrayList<String> getPlFeatures(int plId, Session session) {
    SQLQuery cr = session.createSQLQuery("SELECT fet_name FROM CM.XLP_SE_FEATURE WHERE lower(fet_name)"
            + " not in('pin count','supplier package','product_url','family','life cycle','rohs','standard package name','vendor') "
            + " and pl_id= " + plId + "and COL_NM is not null order by FET_EXPERTSHEETORDER asc");

    @SuppressWarnings("unchecked")
    ArrayList<String> fets = (ArrayList<String>) cr.list();
    return fets;//from   ww w .  ja  v a2  s.co m
}

From source file:com.siemens.scr.avt.ad.api.impl.DefaultADFacadeImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/*  w  w  w  .  j a  v  a  2 s  .  c  o  m*/
public List<ImageAnnotation> retrieveAnnotationsInSeries(String seriesInstanceUID) {
    String queryString = "SELECT i.* FROM AD.IMAGE_ANNOTATION i WHERE annotation_id IN ("
            + "SELECT DISTINCT ia.annotation_id FROM AD.IMAGE_ANNOTATION ia, AD.REFERENCE_IMAGES ri, AD.GENERAL_IMAGE gi, AD.GENERAL_SERIES gs "
            + "WHERE ia.annotation_id = ri.annotation_id AND ri.image_pk_id = gi.image_pk_id "
            + "AND gi.general_series_pk_id = gs.general_series_pk_id " + "AND gs.series_instance_uid = ?)";
    Session session = HibernateUtil.currentSession();

    SQLQuery query = session.createSQLQuery(queryString);
    query.setString(0, seriesInstanceUID);
    query.addEntity(ImageAnnotation.class);

    List<ImageAnnotation> queryResult = query.list();
    return queryResult;
}

From source file:com.siemens.scr.avt.ad.api.impl.DefaultADFacadeImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/*  w  w  w . jav a 2  s .c  om*/
public List<ImageAnnotation> retrieveAnnotationsInSeries(String seriesInstanceUID, String roleInTrial) {
    String queryString = "SELECT i.* FROM AD.IMAGE_ANNOTATION i WHERE annotation_id IN ("
            + "SELECT DISTINCT ia.annotation_id FROM AD.IMAGE_ANNOTATION ia, AD.REFERENCE_IMAGES ri, AD.GENERAL_IMAGE gi, AD.GENERAL_SERIES gs "
            + "WHERE ia.annotation_id = ri.annotation_id AND ri.image_pk_id = gi.image_pk_id "
            + "AND gi.general_series_pk_id = gs.general_series_pk_id "
            + "AND gs.series_instance_uid = ? AND role_in_trial = ?)";
    Session session = HibernateUtil.currentSession();

    SQLQuery query = session.createSQLQuery(queryString);
    query.setString(0, seriesInstanceUID);
    query.setString(1, roleInTrial);
    query.addEntity(ImageAnnotation.class);

    List<ImageAnnotation> queryResult = query.list();
    return queryResult;
}

From source file:com.siemens.scr.avt.ad.api.impl.DefaultADFacadeImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override//from   w  w  w . j a v  a2  s  . co  m
public List<DicomObject> retrieveSegmentationObjects(String annotationUID) {
    Session session = HibernateUtil.currentSession();

    String queryString = "SELECT * FROM AD.GENERAL_IMAGE i, AD.GENERAL_SERIES s, AD.STUDY st, AD.PATIENT p "
            + "WHERE p.PATIENT_PK_ID = st.PATIENT_PK_ID " + "AND st.STUDY_PK_ID = s.STUDY_PK_ID "
            + "AND s.GENERAL_SERIES_PK_ID = i.GENERAL_SERIES_PK_ID " + "AND SOP_INSTANCE_UID IN "
            + "(SELECT X.SEGMENTATION_UID FROM AD.IMAGE_ANNOTATION a, "
            + "   XMLTABLE ('declare default element namespace \"gme://caCORE.caCORE/3.2/edu.northwestern.radiology.AIM\"; "
            + "$aim/imageAnnotation/probabilityMapCollection/ProbabilityMap' passing a.AIM_OBJECT as \"aim\" "
            + "COLUMNS SEGMENTATION_UID VARCHAR(64) PATH '@referencedInstanceUID') AS X WHERE a.ANNOTATION_UID = ?) "
            + "UNION ALL " + "SELECT * FROM AD.GENERAL_IMAGE i, AD.GENERAL_SERIES s, AD.STUDY st, AD.PATIENT p "
            + "WHERE p.PATIENT_PK_ID = st.PATIENT_PK_ID " + "AND st.STUDY_PK_ID = s.STUDY_PK_ID "
            + "AND s.GENERAL_SERIES_PK_ID = i.GENERAL_SERIES_PK_ID " + "AND SOP_INSTANCE_UID IN "
            + "(SELECT X.SEGMENTATION_UID FROM AD.IMAGE_ANNOTATION a, "
            + "   XMLTABLE ('declare default element namespace \"gme://caCORE.caCORE/3.2/edu.northwestern.radiology.AIM\"; "
            + "$aim/ImageAnnotation/segmentationCollection/Segmentation' passing a.AIM_OBJECT as \"aim\" "
            + "COLUMNS SEGMENTATION_UID VARCHAR(64) PATH '@referencedSopInstanceUID') AS X WHERE a.ANNOTATION_UID = ?)";

    SQLQuery query = session.createSQLQuery(queryString);
    query.setString(0, annotationUID);
    query.setString(1, annotationUID);
    query.addEntity(GeneralImage.class).addEntity(GeneralSeries.class).addEntity(GeneralStudy.class)
            .addEntity(Patient.class);

    List<Object[]> queryResult = new ArrayList<Object[]>();
    List<Object[]> tmpqueryResult = query.list();
    queryResult.addAll(tmpqueryResult);

    LinkedList<DicomObject> result = new LinkedList<DicomObject>();
    for (Object[] tuple : queryResult) {
        BasicDicomObject dcmObj = new BasicDicomObject();

        GeneralImage image = (GeneralImage) tuple[0];
        GeneralSeries series = (GeneralSeries) tuple[1];
        GeneralStudy study = (GeneralStudy) tuple[2];
        Patient patient = (Patient) tuple[3];

        image.getDicomObject().copyTo(dcmObj);
        series.getDicomObject().copyTo(dcmObj);
        study.getDicomObject().copyTo(dcmObj);
        patient.getDicomObject().copyTo(dcmObj);
        result.add(dcmObj);
    }
    return result;
}

From source file:com.siemens.scr.avt.ad.query.Queries.java

License:Open Source License

/**
 * Find all the DICOM object in the database satisfying given criteria.
 * /*w  w w . j  ava 2  s  . c  o m*/
 * @param dicomCriteria a map from DICOM tag to java.lang.Object representing a conjunctive query.
 * @param annotationCriteria a map from predefined keys to java.lang.Object representing a conjunctive query.
 * @param includingPixel indicating whether to include pixel data.
 * @return a list of DicomObject satisfying given criteria.
 */
@SuppressWarnings("unchecked")
public static List<DicomObject> findDicomByCriteria(Map<Integer, Object> dicomCriteria,
        Map<String, Object> annotationCriteria, boolean includingPixel) {
    AbstractQueryBuilder builder = new DB2QueryBuilder();

    LinkedList<String> output = new LinkedList<String>();
    output.add(Patient.class.getCanonicalName());
    output.add(GeneralStudy.class.getCanonicalName());
    output.add(GeneralSeries.class.getCanonicalName());
    output.add(GeneralImage.class.getCanonicalName());
    String queryString = builder.buildQuery(dicomCriteria, annotationCriteria, output);

    logger.debug("Query:" + queryString);

    Session session = HibernateUtil.getSessionFactory().openSession();

    SQLQuery query = session.createSQLQuery(queryString);
    query.addEntity(Patient.class).addEntity(GeneralStudy.class).addEntity(GeneralSeries.class)
            .addEntity(GeneralImage.class);

    List<Object[]> queryResult = query.list();

    LinkedList<DicomObject> result = new LinkedList<DicomObject>();

    for (Object[] tuple : queryResult) {
        BasicDicomObject dcmObj = new BasicDicomObject();
        Patient patient = (Patient) tuple[0];
        GeneralStudy study = (GeneralStudy) tuple[1];
        GeneralSeries series = (GeneralSeries) tuple[2];
        GeneralImage image = (GeneralImage) tuple[3];
        image.getDicomObject().copyTo(dcmObj);
        series.getDicomObject().copyTo(dcmObj);
        study.getDicomObject().copyTo(dcmObj);
        patient.getDicomObject().copyTo(dcmObj);
        if (includingPixel) {
            File file = new File(
                    Config.getConfig().getAdDicomStore() + File.separator + dcmObj.getString(0x00080018));
            try {
                FileInputStream input = new FileInputStream(file);
                DicomInputStream dcmInput = new DicomInputStream(input);
                DicomObject dcm = dcmInput.readDicomObject();
                result.add(dcm);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else
            result.add(dcmObj);
    }

    session.close();

    return result;
}

From source file:com.sip.pe.dao.ClienteDAO.java

public List<Object> ObtenerHistorialCliente(int idCliente) {

    List<Object> listaHistorial = null;

    SessionFactory sesFact = HibernateUtil.getSessionFactory();
    Session ses = sesFact.openSession();

    try {/*from w w w.  j av  a  2  s.  c  o  m*/

        SQLQuery q = ses.createSQLQuery("exec sp_ObtenerHistorialCliente :IdCliente");

        q.addScalar("ID_TRANSACCION", INTEGER);
        q.addScalar("FE_TRANSACCION");
        q.addScalar("TIPO_CUENTA");
        q.addScalar("SERVICIO");
        q.addScalar("ENTIDAD");
        q.addScalar("BANCO");
        q.addScalar("NU_CUENTA");
        q.addScalar("IMPORTE_PAGO", FLOAT);

        q.setInteger("IdCliente", idCliente);
        listaHistorial = q.list();

    } catch (HibernateException e) {
        System.out.println("Error en la aplicacion: " + e.toString());
        System.out.println("causa: " + e.getClass());
        e.printStackTrace();
    } finally {
        ses.close();
    }
    return listaHistorial;
}

From source file:com.sistcontable.dao.CuentaDAO.java

public void searchCuentaByID(String id) {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();//from w w w .  j  av  a2s.c o m
    List<Cuenta> lista = new ArrayList();
    try {
        String query = "select * from cuenta where ID_CUENTA=:idCuenta";
        SQLQuery sqlQuery = session.createSQLQuery(query);
        sqlQuery.addEntity(Cuenta.class);
        sqlQuery.setParameter("idCuenta", id);
        List result = sqlQuery.list();

        for (int i = 0; i < result.size(); i++) {
            System.out.println("id: ");
            Cuenta cuenta = (Cuenta) result.get(i);

            System.out.println("idCuenta: " + cuenta.getIdCuenta());
            System.out.println("estado: " + cuenta.getEstado().getNombreEstado());
            System.out.println("rubro: " + cuenta.getRubro().getNombreRubro());
            System.out.println("nombreCuenta: " + cuenta.getNombreCuenta());
            System.out.println("cuentaMayor: " + cuenta.getCuentaMayor());
        }
    } catch (Exception e) {
        System.out.println("ERROR " + e);
        lista = null;
    } finally {
        session.close();
    }
}

From source file:com.sistcontable.dao.CuentaDAO.java

public Cuenta obtenerCuentaByID(String id) {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();//w  w  w .  j ava  2  s .com
    List<Cuenta> lista = new ArrayList();
    try {
        String query = "select * from cuenta where ID_CUENTA=:idCuenta";
        SQLQuery sqlQuery = session.createSQLQuery(query);
        sqlQuery.addEntity(Cuenta.class);
        sqlQuery.setParameter("idCuenta", id);
        List result = sqlQuery.list();

        for (int i = 0; i < result.size(); i++) {
            System.out.println("id: ");
            Cuenta cuenta = (Cuenta) result.get(i);

            System.out.println("idCuenta: " + cuenta.getIdCuenta());
            System.out.println("estado: " + cuenta.getEstado().getNombreEstado());
            System.out.println("rubro: " + cuenta.getRubro().getNombreRubro());
            System.out.println("nombreCuenta: " + cuenta.getNombreCuenta());
            System.out.println("cuentaMayor: " + cuenta.getCuentaMayor());
        }
        return (Cuenta) result.get(0);
    } catch (Exception e) {
        System.out.println("ERROR " + e);
        lista = null;
        return null;
    } finally {
        session.close();
    }
}

From source file:com.sistcontable.dao.CuentaDAO.java

public List<Cuenta> searchAllCuentas() {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();/*from w  w w.ja  v  a  2  s.  c o m*/
    List<Cuenta> lista = new ArrayList();
    try {
        String query = "select * from cuenta order by ID_CUENTA";
        SQLQuery sqlQuery = session.createSQLQuery(query);
        sqlQuery.addEntity(Cuenta.class);
        lista = sqlQuery.list();

        for (int i = 0; i < lista.size(); i++) {
            System.out.println("-------------------------------------------------");
            System.out.println("idCuenta: " + lista.get(i).getIdCuenta());
            System.out.println("estado: " + lista.get(i).getEstado().getNombreEstado());
            System.out.println("rubro: " + lista.get(i).getRubro().getNombreRubro());
            System.out.println("nombreCuenta: " + lista.get(i).getNombreCuenta());
            System.out.println("cuentaMayor: " + lista.get(i).getCuentaMayor());
        }

    } catch (Exception e) {
        System.out.println("ERROR " + e);
        lista = null;
    } finally {
        session.close();
    }
    return lista;
}