Example usage for org.hibernate SQLQuery scroll

List of usage examples for org.hibernate SQLQuery scroll

Introduction

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

Prototype

ScrollableResults scroll();

Source Link

Document

Return the query results as ScrollableResults.

Usage

From source file:com.duroty.application.files.manager.FilesManager.java

License:Open Source License

/**
 * DOCUMENT ME!//  w  w  w . ja v a 2s.  c  o m
 *
 * @param hsession DOCUMENT ME!
 * @param repositoryName DOCUMENT ME!
 * @param folderName DOCUMENT ME!
 * @param page DOCUMENT ME!
 * @param messagesByPage DOCUMENT ME!
 * @param order DOCUMENT ME!
 * @param orderType DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 *
 * @throws FilesException DOCUMENT ME!
 */
public Vector getFiles(Session hsession, String repositoryName, String folderName, int label, int page,
        int messagesByPage, int order, String orderType) throws FilesException {
    Vector files = new Vector();

    try {
        Users user = getUser(hsession, repositoryName);
        Locale locale = new Locale(user.getUseLanguage());
        TimeZone timeZone = TimeZone.getDefault();

        Date now = new Date();
        Calendar calendar = Calendar.getInstance(timeZone, locale);
        calendar.setTime(now);

        SimpleDateFormat formatter1 = new SimpleDateFormat("MMM dd", locale);
        SimpleDateFormat formatter2 = new SimpleDateFormat("HH:mm:ss", locale);
        SimpleDateFormat formatter3 = new SimpleDateFormat("MM/yy", locale);

        Query hquery = null;

        String[] folderNameList = new String[0];

        try {
            folderName = parseFolder(folderName);

            folderNameList = new String[] { folderName };

            if (folderName.equals(this.folderAll) || folderName.equals(this.folderHidden)) {
                folderNameList = new String[] { this.folderAll, this.folderDraft, this.folderHidden,
                        this.folderImportant, this.folderInbox, this.folderSent };
            }
        } catch (Exception ex) {
        }

        if ((folderNameList.length == 0) && (label <= 0)) {
            hquery = hsession.getNamedQuery("attachments");
        } else if ((folderNameList.length > 0) && (label <= 0)) {
            hquery = hsession.getNamedQuery("attachments-by-folder");
        } else if ((folderNameList.length == 0) && (label > 0)) {
            hquery = hsession.getNamedQuery("attachments-by-label");
        } else if ((folderNameList.length > 0) && (label > 0)) {
            hquery = hsession.getNamedQuery("attachments-by-folder-label");
        }

        String aux = hquery.getQueryString();

        switch (order) {
        case ORDER_BY_SIZE:

            if (orderType.equals("ASC")) {
                aux += " order by att_size asc";
            } else {
                aux += " order by att_size desc";
            }

            break;

        case ORDER_BY_DATE:

            if (orderType.equals("ASC")) {
                aux += " order by mes_date asc";
            } else {
                aux += " order by mes_date desc";
            }

            break;

        case ORDER_BY_TYPE:

            if (orderType.equals("ASC")) {
                aux += " order by att_content_type asc";
            } else {
                aux += " order by att_content_type desc";
            }

            break;

        default:

            if (!orderType.equals("ASC")) {
                aux += " order by att_name desc";
            } else {
                aux += " order by att_name asc";
            }

            break;
        }

        SQLQuery h2query = hsession.createSQLQuery(aux);

        if ((folderNameList.length == 0) && (label <= 0)) {
            h2query.setParameterList("no_boxes",
                    new String[] { this.folderTrash, this.folderChat, this.folderSpam, FOLDER_DELETE });
            h2query.setInteger("user", getUser(hsession, repositoryName).getUseIdint());
        } else if ((folderNameList.length > 0) && (label <= 0)) {
            h2query.setParameterList("boxes", folderNameList);
            h2query.setInteger("user", getUser(hsession, repositoryName).getUseIdint());
        } else if ((folderNameList.length == 0) && (label > 0)) {
            h2query.setInteger("label", label);
            h2query.setParameterList("no_boxes",
                    new String[] { this.folderTrash, this.folderChat, this.folderSpam, FOLDER_DELETE });
            h2query.setInteger("user", getUser(hsession, repositoryName).getUseIdint());
        } else if ((folderNameList.length > 0) && (label > 0)) {
            h2query.setInteger("label", label);
            h2query.setParameterList("boxes", folderNameList);
            h2query.setInteger("user", getUser(hsession, repositoryName).getUseIdint());
        }

        h2query.setFirstResult(page * messagesByPage);
        h2query.setMaxResults(messagesByPage);

        h2query.addEntity("testo", AttachmentWithDate.class);

        ScrollableResults scroll = h2query.scroll();

        while (scroll.next()) {
            AttachmentWithDate attachment = (AttachmentWithDate) scroll.get(0);

            AttachmentObj obj = new AttachmentObj();
            obj.setContentType(attachment.getAttContentType());

            Date date = attachment.getAttDate();

            if (date != null) {
                Calendar calendar2 = Calendar.getInstance(timeZone, locale);
                calendar2.setTime(date);

                if ((calendar.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR))
                        && (calendar.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH))
                        && (calendar.get(Calendar.DATE) == calendar2.get(Calendar.DATE))) {
                    obj.setDateStr(formatter2.format(calendar2.getTime()));
                } else if (calendar.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR)) {
                    obj.setDateStr(formatter1.format(calendar2.getTime()));
                } else {
                    obj.setDateStr(formatter3.format(calendar2.getTime()));
                }
            }

            obj.setDate(date);

            obj.setDate(date);
            obj.setIdint(attachment.getAttIdint());
            obj.setName(attachment.getAttName());
            obj.setPart(attachment.getAttPart());

            int size = attachment.getAttSize();
            size /= 1024;

            if (size > 1024) {
                size /= 1024;
                obj.setSize(size + " MB");
            } else {
                obj.setSize(((size > 0) ? (size + "") : "<1") + " kB");
            }

            String extension = (String) this.extensions.get(attachment.getAttContentType());

            if (StringUtils.isBlank(extension)) {
                extension = "generic";
            }

            obj.setExtension(extension);

            Message message = attachment.getMessage();

            if (message.isMesFlagged()) {
                obj.setFlagged(true);
            } else {
                obj.setFlagged(false);
            }

            if (message.getLabMeses() != null) {
                Iterator it = message.getLabMeses().iterator();
                StringBuffer lab = new StringBuffer();

                while (it.hasNext()) {
                    if (lab.length() > 0) {
                        lab.append(", ");
                    }

                    LabMes labMes = (LabMes) it.next();
                    lab.append(labMes.getId().getLabel().getLabName());
                }

                if (lab.length() > 0) {
                    obj.setLabel(lab.toString());
                } else {
                }
            }

            obj.setBox(message.getMesBox());

            obj.setMid(message.getMesName());

            files.addElement(obj);
        }

        return files;
    } catch (Exception e) {
        throw new FilesException(e);
    } finally {
        GeneralOperations.closeHibernateSession(hsession);
    }
}

From source file:com.duroty.application.mail.manager.MailManager.java

License:Open Source License

/**
 * DOCUMENT ME!//ww w.  ja  v  a  2 s  .  c o  m
 *
 * @param hsession DOCUMENT ME!
 * @param repositoryName DOCUMENT ME!
 * @param label DOCUMENT ME!
 * @param page DOCUMENT ME!
 * @param messagesByPage DOCUMENT ME!
 * @param order DOCUMENT ME!
 * @param orderType DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 *
 * @throws MailException DOCUMENT ME!
 */
public Vector getMessages(Session hsession, String repositoryName, Label label, int page, int messagesByPage,
        int order, String orderType) throws MailException {
    Vector messages = new Vector();

    try {
        Users user = getUser(hsession, repositoryName);
        Locale locale = new Locale(user.getUseLanguage());
        TimeZone timeZone = TimeZone.getDefault();

        Date now = new Date();
        Calendar calendar = Calendar.getInstance(timeZone, locale);
        calendar.setTime(now);

        SimpleDateFormat formatter1 = new SimpleDateFormat("MMM dd", locale);
        SimpleDateFormat formatter2 = new SimpleDateFormat("HH:mm:ss", locale);
        SimpleDateFormat formatter3 = new SimpleDateFormat("MM/yy", locale);

        Query hquery = hsession.getNamedQuery("messages-by-label");
        String aux = hquery.getQueryString();

        switch (order) {
        case ORDER_BY_IMPORTANT:

            if (orderType.equals("ASC")) {
                aux += " order by mes_flagged asc";
            } else {
                aux += " order by mes_flagged desc";
            }

            break;

        case ORDER_BY_ADDRESS:

            if (orderType.equals("ASC")) {
                aux += " order by mes_from asc";
            } else {
                aux += " order by mes_from desc";
            }

            break;

        case ORDER_BY_SIZE:

            if (orderType.equals("ASC")) {
                aux += " order by mes_size asc";
            } else {
                aux += " order by mes_size desc";
            }

            break;

        case ORDER_BY_SUBJECT:

            if (orderType.equals("ASC")) {
                aux += " order by mes_subject asc";
            } else {
                aux += " order by mes_subject desc";
            }

            break;

        case ORDER_BY_DATE:

            if (orderType.equals("ASC")) {
                aux += " order by mes_date asc";
            } else {
                aux += " order by mes_date desc";
            }

            break;

        case ORDER_BY_UNREAD:

            if (orderType.equals("ASC")) {
                aux += " order by mes_recent asc";
            } else {
                aux += " order by mes_recent desc";
            }

            break;

        default:
            aux += " order by mes_date desc";

            break;
        }

        SQLQuery h2query = hsession.createSQLQuery(aux);
        h2query.addEntity("i", Message.class);
        h2query.setInteger("label", label.getLabIdint());
        h2query.setInteger("user", user.getUseIdint());
        h2query.setString("folderTrash", this.folderTrash);
        h2query.setString("folderSpam", this.folderSpam);
        h2query.setString("folderDelete", FOLDER_DELETE);
        h2query.setFirstResult(page * messagesByPage);
        h2query.setMaxResults(messagesByPage);

        ScrollableResults scroll = h2query.scroll();

        while (scroll.next()) {
            Message message = (Message) scroll.get(0);

            MessageObj obj = new MessageObj(message.getMesName());

            obj.setBox(message.getMesBox());

            obj.setFrom(message.getMesFrom());

            if ((message.getAttachments() != null) && (message.getAttachments().size() > 0)) {
                obj.setHasAttachment(true);
            } else {
                obj.setHasAttachment(false);
            }

            int size = message.getMesSize();
            size /= 1024;

            if (size > 1024) {
                size /= 1024;
                obj.setSize(size + " MB");
            } else {
                obj.setSize(((size > 0) ? (size + "") : "<1") + " kB");
            }

            if (message.getMesBox().equals(folderSent)) {
                try {
                    obj.setEmail(message.getMesTo());
                } catch (Exception e) {
                    obj.setEmail("unknown to");
                }
            } else {
                obj.setEmail(message.getMesFrom());
            }

            Date date = message.getMesDate();

            if (date != null) {
                Calendar calendar2 = Calendar.getInstance(timeZone, locale);
                calendar2.setTime(date);

                if ((calendar.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR))
                        && (calendar.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH))
                        && (calendar.get(Calendar.DATE) == calendar2.get(Calendar.DATE))) {
                    obj.setDateStr(formatter2.format(calendar2.getTime()));
                } else if (calendar.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR)) {
                    obj.setDateStr(formatter1.format(calendar2.getTime()));
                } else {
                    obj.setDateStr(formatter3.format(calendar2.getTime()));
                }
            }

            obj.setDate(date);

            if (message.getLabMeses() != null) {
                Iterator it = message.getLabMeses().iterator();
                StringBuffer buff = new StringBuffer();

                while (it.hasNext()) {
                    if (buff.length() > 0) {
                        buff.append(", ");
                    }

                    LabMes labMes = (LabMes) it.next();
                    buff.append(labMes.getId().getLabel().getLabName());
                }

                obj.setLabel(buff.toString());
            }

            try {
                if (StringUtils.isBlank(message.getMesSubject())) {
                    obj.setSubject("(no subject)");
                } else {
                    obj.setSubject(message.getMesSubject());
                }
            } catch (Exception ex) {
                obj.setSubject("(no subject)");
            }

            if (message.isMesFlagged()) {
                obj.setFlagged(true);
            } else {
                obj.setFlagged(false);
            }

            if (message.isMesRecent()) {
                obj.setRecent(true);
            } else {
                obj.setRecent(false);
            }

            String priority = "normal";

            if (MessageUtilities.isHighPriority(message.getMesHeaders())) {
                priority = "high";
            } else if (MessageUtilities.isLowPriority(message.getMesHeaders())) {
                priority = "low";
            }

            obj.setPriority(priority);

            messages.addElement(obj);
        }

        return messages;
    } catch (Exception e) {
        throw new MailException(e);
    } finally {
        GeneralOperations.closeHibernateSession(hsession);
    }
}

From source file:edu.vt.vbi.patric.dao.DBDisease.java

License:Apache License

public List<ResultType> getVFDBList(Map<String, String> key, Map<String, String> sort, int start, int end) {

    String sql = "";

    sql += getVFDBSQL(key, "function");

    sql += " GROUP BY vfg_id, gene_name, gene_product, vf_id, vf_name, vf_fullname, function ";

    if (sort != null && sort.containsKey("field") && sort.get("field") != null && sort.containsKey("direction")
            && sort.get("direction") != null) {

        sql += " ORDER BY " + sort.get("field") + " " + sort.get("direction");

    } else {/*ww  w  .ja  v a 2  s .c  om*/

        sql += " ORDER BY b.vfg_id, b.gene_name";
    }

    Session session = factory.getCurrentSession();
    session.beginTransaction();
    SQLQuery q = session.createSQLQuery(sql);
    q = bindVFDBSQLValues(q, key);

    if (end > 0) {
        q.setMaxResults(end);
    }

    ScrollableResults scr = q.scroll();
    List<ResultType> results = new ArrayList<>();

    if (start > 1) {
        scr.setRowNumber(start - 1);
    } else {
        scr.beforeFirst();
    }

    for (int i = start; (end > 0 && i < end && scr.next()) || (end == -1 && scr.next()); i++) {

        Object[] obj = scr.get();
        ResultType row = new ResultType();
        row.put("vfg_id", obj[0]);
        row.put("gene_name", obj[1]);
        row.put("gene_product", obj[2]);
        row.put("vf_id", obj[3]);
        row.put("vf_name", obj[4]);
        row.put("vf_fullname", obj[5]);
        row.put("function", obj[6]);
        row.put("feature_count", obj[7]);

        results.add(row);
    }

    session.getTransaction().commit();

    return results;

}

From source file:edu.vt.vbi.patric.dao.DBDisease.java

License:Apache License

public List<ResultType> getVFDBFeatureList(Map<String, String> key, Map<String, String> sort, int start,
        int end) {

    String sql = "";

    sql += getVFDBFeatureSQL(key, "function");

    if (sort != null && sort.containsKey("field") && sort.get("field") != null && sort.containsKey("direction")
            && sort.get("direction") != null) {

        sql += " ORDER BY " + sort.get("field") + " " + sort.get("direction");

    } else {/*w w w .  j  a  v a  2s.c o m*/

        sql += " ORDER BY na_feature_id";
    }

    Session session = factory.getCurrentSession();
    session.beginTransaction();
    SQLQuery q = session.createSQLQuery(sql);
    q = bindVFDBFeatureSQLValues(q, key);

    if (end > 0) {
        q.setMaxResults(end);
    }

    ScrollableResults scr = q.scroll();
    List<ResultType> results = new ArrayList<>();

    if (start > 1) {
        scr.setRowNumber(start - 1);
    } else {
        scr.beforeFirst();
    }

    for (int i = start; (end > 0 && i < end && scr.next()) || (end == -1 && scr.next()); i++) {
        Object[] obj = scr.get();
        ResultType row = new ResultType();
        row.put("vf_id", obj[0]);
        row.put("vf_name", obj[1]);
        row.put("vfg_id", obj[2]);
        row.put("gene_name", obj[3]);
        row.put("na_feature_id", obj[4]);
        row.put("genome_info_id", obj[5]);
        row.put("genome_name", obj[6]);
        row.put("accession", obj[7]);
        row.put("locus_tag", obj[8]);
        row.put("product", obj[9]);
        row.put("genome_id", obj[10]);
        row.put("feature_id", obj[11]);
        row.put("patric_id", obj[12]);
        row.put("refseq_locus_tag", obj[13]);
        row.put("alt_locus_tag", obj[14]);

        results.add(row);
    }

    session.getTransaction().commit();

    return results;

}

From source file:edu.vt.vbi.patric.dao.DBDisease.java

License:Apache License

public List<ResultType> getCTDList(Map<String, String> key, Map<String, String> sort, int start, int end) {

    String sql = "";

    sql += getCTDSQL(key, "function");

    if (sort != null && sort.containsKey("field") && sort.get("field") != null && sort.containsKey("direction")
            && sort.get("direction") != null) {

        sql += " ORDER BY " + sort.get("field") + " " + sort.get("direction");

    } else {//from   w  w w.j av a 2  s  .  com

        sql += " ORDER BY cs.gene_sym, cs.disease_name";
    }

    Session session = factory.getCurrentSession();
    session.beginTransaction();
    SQLQuery q = session.createSQLQuery(sql);
    q = bindSQLValues(q, key);

    if (end > 0) {
        q.setMaxResults(end);
    }

    ScrollableResults scr = q.scroll();
    List<ResultType> results = new ArrayList<>();

    if (start > 1) {
        scr.setRowNumber(start - 1);
    } else {
        scr.beforeFirst();
    }

    for (int i = start; (end > 0 && i < end && scr.next()) || (end == -1 && scr.next()); i++) {

        Object[] obj = scr.get();
        ResultType row = new ResultType();
        row.put("gene_sym", obj[0]);
        row.put("gene_id", obj[1]);
        row.put("gene_disease_rel", obj[2]);
        row.put("disease_name", obj[3]);
        row.put("pubmed_id", obj[4]);
        row.put("disease_id", obj[5]);
        row.put("gd_app_name", obj[6]);

        results.add(row);
    }

    session.getTransaction().commit();

    return results;

}

From source file:edu.vt.vbi.patric.dao.DBDisease.java

License:Apache License

public List<ResultType> getCTDGraphList(Map<String, String> key, Map<String, String> sort, int start, int end) {

    String sql = "";

    sql += getCTDSQL(key, "graphlist");

    if (sort != null && sort.containsKey("field") && sort.get("field") != null && sort.containsKey("direction")
            && sort.get("direction") != null) {

        sql += " ORDER BY " + sort.get("field") + " " + sort.get("direction");

    } else {/*from   w ww  .  j a  v  a2 s.  c  o m*/

        sql += " ORDER BY cs.gene_sym, cs.disease_name";
    }

    Session session = factory.getCurrentSession();
    session.beginTransaction();
    SQLQuery q = session.createSQLQuery(sql);
    q = bindGraphCTDSQLValues(q, key);

    if (end > 0) {
        q.setMaxResults(end);
    }

    ScrollableResults scr = q.scroll();
    List<ResultType> results = new ArrayList<>();

    if (start > 1) {
        scr.setRowNumber(start - 1);
    } else {
        scr.beforeFirst();
    }

    for (int i = start; (end > 0 && i < end && scr.next()) || (end == -1 && scr.next()); i++) {

        Object[] obj = scr.get();
        ResultType row = new ResultType();
        row.put("gene_sym", obj[0]);
        row.put("gene_id", obj[1]);
        row.put("gene_disease_rel", obj[2]);
        row.put("disease_name", obj[3]);
        row.put("pubmed_id", obj[4]);
        row.put("disease_id", obj[5]);
        row.put("gd_app_name", obj[6]);

        results.add(row);
    }

    session.getTransaction().commit();

    return results;

}

From source file:edu.vt.vbi.patric.dao.DBDisease.java

License:Apache License

public List<ResultType> getGADGraphList(Map<String, String> key, Map<String, String> sort, int start, int end) {

    String sql = "";

    sql += getGADSQL(key, "graphlist");

    if (sort != null && sort.containsKey("field") && sort.get("field") != null && sort.containsKey("direction")
            && sort.get("direction") != null) {

        sql += " ORDER BY " + sort.get("field") + " " + sort.get("direction");

    } else {//  ww w .  jav a  2s  .  c  o m

        sql += " ORDER BY gs.gene_sym";
    }

    Session session = factory.getCurrentSession();
    session.beginTransaction();
    SQLQuery q = session.createSQLQuery(sql);
    q = bindGraphGADSQLValues(q, key);

    if (end > 0) {
        q.setMaxResults(end);
    }

    ScrollableResults scr = q.scroll();
    List<ResultType> results = new ArrayList<>();

    if (start > 1) {
        scr.setRowNumber(start - 1);
    } else {
        scr.beforeFirst();
    }

    for (int i = start; (end > 0 && i < end && scr.next()) || (end == -1 && scr.next()); i++) {

        Object[] obj = scr.get();
        ResultType row = new ResultType();
        row.put("gene_sym", obj[0]);
        row.put("gene_id", obj[1]);
        row.put("association", obj[2]);
        row.put("mesh_disease_terms", obj[3]);
        row.put("broad_phenotype", obj[4]);
        row.put("pubmed_id", obj[5]);
        row.put("conclusion", obj[6]);
        row.put("gd_app_name", obj[7]);

        results.add(row);
    }

    session.getTransaction().commit();

    return results;
}

From source file:edu.vt.vbi.patric.dao.DBDisease.java

License:Apache License

public List<ResultType> getGADList(Map<String, String> key, Map<String, String> sort, int start, int end) {

    String sql = "";

    sql += getGADSQL(key, "function");

    if (sort != null && sort.containsKey("field") && sort.get("field") != null && sort.containsKey("direction")
            && sort.get("direction") != null) {

        sql += " ORDER BY " + sort.get("field") + " " + sort.get("direction");

    } else {//from  w w  w. ja  va  2  s. co m

        sql += " ORDER BY gs.gene_sym";
    }

    Session session = factory.getCurrentSession();
    session.beginTransaction();
    SQLQuery q = session.createSQLQuery(sql);
    q = bindSQLValues(q, key);

    if (end > 0) {
        q.setMaxResults(end);
    }

    ScrollableResults scr = q.scroll();
    List<ResultType> results = new ArrayList<>();

    if (start > 1) {
        scr.setRowNumber(start - 1);
    } else {
        scr.beforeFirst();
    }

    for (int i = start; (end > 0 && i < end && scr.next()) || (end == -1 && scr.next()); i++) {

        Object[] obj = scr.get();
        ResultType row = new ResultType();
        row.put("gene_sym", obj[0]);
        row.put("gene_id", obj[1]);
        row.put("association", obj[2]);
        row.put("mesh_disease_terms", obj[3]);
        row.put("broad_phenotype", obj[4]);
        row.put("pubmed_id", obj[5]);
        row.put("conclusion", obj[6]);
        row.put("gd_app_name", obj[7]);

        results.add(row);
    }

    session.getTransaction().commit();

    return results;
}

From source file:edu.vt.vbi.patric.dao.DBPRC.java

License:Apache License

public ArrayList<ResultType> getPRCData(String taxonId, String filter, int start, int end, String sort,
        String dir) {/*w  w w.  j a v  a 2 s  .c  o m*/

    String sql = "select distinct experiment_id, description, speciesname, processing_type, summary, pubmed_id, count(distinct sample_id) from app.post_genomic";
    if (filter.equals("MS"))
        sql += " where processing_type = 'Mass spectrometry'";
    else if (filter.equals("MA"))
        sql += " where processing_type = 'Microarray'";
    else
        sql += " where processing_type = 'Protein interaction'";
    sql += " and taxon_id in (" + DBSummary.getTaxonIdsInTaxonSQL(":taxonId") + ")";
    sql += " group by experiment_id, description, speciesname, processing_type, summary, pubmed_id";
    sql += " order by " + sort + " " + dir;

    Session session = factory.getCurrentSession();
    session.beginTransaction();
    SQLQuery q = session.createSQLQuery(sql);

    q.setTimeout(SQL_TIMEOUT);
    q.setString("taxonId", taxonId);

    ScrollableResults scr = null;

    try {
        scr = q.scroll();
    } catch (Exception ex) {
        System.out.println("[SQL error]" + taxonId);
        ex.printStackTrace();
        return null;
    }

    ArrayList<ResultType> results = new ArrayList<ResultType>();
    Object[] obj = null;
    if (start > 1) {
        scr.setRowNumber(start - 1);
    } else {
        scr.beforeFirst();
    }

    for (int i = start; (end > 0 && i < end && scr.next() == true) || (end == -1 && scr.next() == true); i++) {
        obj = scr.get();
        ResultType row = new ResultType();

        row.put("experiment_id", obj[0]);
        row.put("description", obj[1]);
        row.put("speciesname", obj[2]);
        row.put("experimenttype", obj[3]);
        row.put("summary", obj[4]);
        row.put("pubmed_id", obj[5]);
        row.put("samples", obj[6]);
        results.add(row);
    }
    session.getTransaction().commit();
    return results;
}

From source file:gov.nih.nci.caarray.plugins.nimblegen.NdfHandler.java

License:BSD License

ScrollableResults getProbes() {
    final SQLQuery q = this.hibernateHelper.getCurrentSession()
            .createSQLQuery("select * from " + TEMP_TABLE_NAME + " order by SEQ_ID asc");
    return q.scroll();
}