Example usage for org.hibernate.query NativeQuery list

List of usage examples for org.hibernate.query NativeQuery list

Introduction

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

Prototype

List<R> list();

Source Link

Document

Return the query results as a List.

Usage

From source file:org.openvpms.component.business.dao.hibernate.im.lookup.LookupReplacer.java

License:Open Source License

/**
 * Determines if a lookup is used by a particular archetype 'details' node.
 * <p/>/*from  w  w w .ja  va  2 s  . c  o m*/
 * This uses SQL rather than HQL as HQL cannot query the details table.
 *
 * @param lookup    the lookup to check
 * @param node      the node
 * @param archetype the archetype
 * @param session   the hibernate session
 * @return <tt>true</tt> if the lookup is used, otherwise <tt>false</tt>
 */
private boolean isUsedSQL(Lookup lookup, NodeDescriptor node, ArchetypeDescriptor archetype, Session session) {
    Mapping mapping = getMapping(archetype, node);
    NativeQuery query = session.createSQLQuery(mapping.getIsUsedSQL());
    query.setMaxResults(1);
    query.setParameter("archetype", archetype.getType().getShortName());
    query.setParameter("name", node.getName());
    query.setParameter("code", lookup.getCode());
    return !query.list().isEmpty();
}