List of usage examples for org.hibernate.query NativeQuery setMaxResults
@Override
NativeQuery<T> setMaxResults(int maxResult);
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/>/* ww w . j a va2 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(); }