Example usage for org.hibernate Query setLong

List of usage examples for org.hibernate Query setLong

Introduction

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

Prototype

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

Source Link

Document

Bind a named long-valued parameter.

Usage

From source file:edu.monash.merc.dao.TPBVersionDAO.java

License:Open Source License

/**
 * {@inheritDoc}//from   www. j av  a  2 s. com
 */
public void deleteTPBVersionById(long id) {
    String del_hql = "DELETE FROM " + this.persistClass.getSimpleName() + " AS tpbv WHERE tpbv.id = :id";
    Query query = this.session().createQuery(del_hql);
    query.setLong("id", id);
    query.executeUpdate();
}

From source file:edu.monash.merc.dao.TrafficLightDAO.java

License:Open Source License

/**
 * {@inheritDoc}//from   w w  w  .j a v  a 2s  .  com
 */
public void deleteTLById(long id) {
    String del_hql = "DELETE FROM " + this.persistClass.getSimpleName() + " AS tl WHERE tl.id = :id";
    Query query = this.session().createQuery(del_hql);
    query.setLong("id", id);
    query.executeUpdate();
}

From source file:edu.scripps.fl.pubchem.app.curves.AIDStage.java

License:Apache License

@Override
public void process(Object obj) throws StageException {
    try {/*  w ww .  j  ava2s . com*/
        Integer aid = (Integer) obj;
        List<Double> concentrations = getConcentrations(aid);

        Query query2 = getSession().createQuery("from PCAssayResult where assay.AID = ? and SID = ?");
        // get top 10000 results from reference aid
        int counter = 0;
        Query query = getSession().createQuery(
                "from PCAssayResult where assay.AID = ? AND ( outcome = 'Active' OR outcome = 'Probe' ) ORDER BY rankScore desc");
        query.setInteger(0, getReferenceAID());
        Iterator<PCAssayResult> iter = query.iterate();
        while (iter.hasNext() && counter++ < getTopX()) {
            PCAssayResult referenceResult = iter.next();
            referenceResult.getTestedValues();
            emit(new Object[] { referenceConcentrations, referenceResult });

            query2.setInteger(0, aid);
            query2.setLong(1, referenceResult.getSID());
            Iterator<PCAssayResult> iter2 = query2.iterate();
            while (iter2.hasNext()) {
                PCAssayResult result = iter2.next();
                result.getTestedValues();
                emit(new Object[] { concentrations, result });
            }
        }
    } catch (Exception ex) {
        throw new StageException(this, ex);
    }
}

From source file:edu.scripps.fl.pubchem.app.RelationDownloader.java

License:Apache License

protected void update(long fromId, String name, Collection<Relation> relations) {
    Session session = PubChemDB.getSession();
    Transaction trx = session.beginTransaction();

    Query query = session.createQuery("delete from Relation where fromId = ? and relationName = ?");
    query.setLong(0, fromId);
    query.setString(1, name);//from   w ww .  j ava 2  s.  c o m
    query.executeUpdate();

    for (Relation relation : relations) {
        session.save(relation);
    }
    relations.clear();

    session.flush();
    trx.commit();
}

From source file:edu.ur.hibernate.ir.groupspace.db.HbGroupWorkspaceFileDAO.java

License:Apache License

/**
 * Get a count of files with the specified ir file id.
 * //w  ww  .j  a  va 2s  .c o m
 * @see edu.ur.ir.groupspace.GroupWorkspaceFileDAO#getFileCount(java.lang.Long)
 */
public Long getFileCount(Long irFileId) {
    Query q = hbCrudDAO.getSessionFactory().getCurrentSession()
            .getNamedQuery("getGroupWorkspaceFilesWithIrFileId");
    q.setLong("irFileId", irFileId);
    return (Long) q.uniqueResult();
}

From source file:edu.ur.hibernate.ir.groupspace.db.HbGroupWorkspaceFileDAO.java

License:Apache License

/**
 * Get the files for group workspace id and versioned file id .
 * /*from  w  w w .j a v a  2  s.c om*/
 * @param groupWorkspaceId
 * @param versionedFileId
 * 
 * @return the found file
 */
public GroupWorkspaceFile getGroupWorkspaceFileWithVersionedFile(Long groupWorkspaceId, Long versionedFileId) {
    Query q = hbCrudDAO.getSessionFactory().getCurrentSession()
            .getNamedQuery("getGroupWorkspaceFileWithVersionedFileId");
    q.setLong("groupWorkspaceId", groupWorkspaceId);
    q.setLong("versionedFileId", versionedFileId);
    return (GroupWorkspaceFile) q.uniqueResult();

}

From source file:edu.ur.hibernate.ir.institution.db.HbInstitutionalItemDAO.java

License:Apache License

/**
 * Get a list of items for a specified repository by name.
 * /* w ww.j a v a 2  s. c o  m*/
 * @param rowStart - Start row to fetch the data from
 * @param maxResulsts - maximum number of results to fetch
 * @param repositoryId - id of the collection to get items 
 * @param orderType - The order to sort by (ascending/descending)
 * 
 * @return List of institutional items
 */
@SuppressWarnings("unchecked")
public List<InstitutionalItem> getRepositoryItemsByName(final int rowStart, final int maxResults,
        final Long repositoryId, final OrderType orderType) {
    Session session = hbCrudDAO.getSessionFactory().getCurrentSession();

    Query q = null;
    if (orderType.equals(OrderType.DESCENDING_ORDER)) {
        q = session.getNamedQuery("getRepositoryItemsByNameOrderDesc");
    } else {
        q = session.getNamedQuery("getRepositoryItemsByNameOrderAsc");
    }
    q.setLong("repositoryId", repositoryId);
    q.setFirstResult(rowStart);
    q.setMaxResults(maxResults);
    q.setCacheable(false);
    q.setReadOnly(true);
    q.setFetchSize(maxResults);
    return q.list();

}

From source file:edu.ur.hibernate.ir.institution.db.HbInstitutionalItemDAO.java

License:Apache License

/**
 * Get a list of items for a specified repository by first character of the name
 * //from   w w  w  .  ja  v a2 s.  com
 * @param rowStart - Start row to fetch the data from
 * @param maxResulsts - maximum number of results to fetch
 * @param repositoryId - id of the repository to get items 
 * @param firstChar - first character that the name should have
 * @param orderType - The order to sort by (asc/desc)
 * 
 * @return List of institutional items
 */
@SuppressWarnings("unchecked")
public List<InstitutionalItem> getRepositoryItemsByChar(final int rowStart, final int maxResults,
        final Long repositoryId, final char firstChar, final OrderType orderType) {
    Session session = hbCrudDAO.getSessionFactory().getCurrentSession();

    Query q = null;
    if (orderType.equals(OrderType.DESCENDING_ORDER)) {
        q = session.getNamedQuery("getRepositoryItemsByCharOrderDesc");
    } else {
        q = session.getNamedQuery("getRepositoryItemsByCharOrderAsc");
    }
    q.setLong("repositoryId", repositoryId);
    q.setCharacter("firstChar", Character.toLowerCase(firstChar));
    q.setFirstResult(rowStart);
    q.setMaxResults(maxResults);
    q.setFetchSize(maxResults);
    return q.list();
}

From source file:edu.ur.hibernate.ir.institution.db.HbInstitutionalItemDAO.java

License:Apache License

/**
 * Get a list of items for a specified repository by between the that have titles
 * that start between the specified characters
 * /*from w  w  w. j  a v a 2s .c o m*/
 * @param rowStart - Start row to fetch the data from
 * @param maxResulsts - maximum number of results to fetch
 * @param repositoryId - id of the repository to get items 
 * @param firstChar - first character in range that the first letter of the name can have
 * @param lastChar - last character in range that the first letter of the name can have
 * @param orderType - The order to sort by (asc/desc)
 * 
 * @return List of institutional items
 */
@SuppressWarnings("unchecked")
public List<InstitutionalItem> getRepositoryItemsBetweenChar(final int rowStart, final int maxResults,
        final Long repositoryId, final char firstChar, final char lastChar, final OrderType orderType) {
    Session session = hbCrudDAO.getSessionFactory().getCurrentSession();

    Query q = null;
    if (orderType.equals(OrderType.DESCENDING_ORDER)) {
        q = session.getNamedQuery("getRepositoryItemsByCharRangeOrderDesc");
    } else {
        q = session.getNamedQuery("getRepositoryItemsByCharRangeOrderAsc");
    }
    q.setLong("repositoryId", repositoryId);
    q.setCharacter("firstChar", Character.toLowerCase(firstChar));
    q.setCharacter("lastChar", Character.toLowerCase(lastChar));
    q.setFirstResult(rowStart);
    q.setMaxResults(maxResults);
    q.setFetchSize(maxResults);
    return q.list();

}