List objs = hibernate.findByNamedQueryAndNamedParam(queryName, "value", value);
final Criterion expression = Restrictions.eq(propName, propValue); HibernateCallback callback = new HibernateCallback() { public Object doInHibernate(Session session) { Criteria criteria = session.createCriteria(obj.getClass()).add(expression) .setProjection(Projections.property(ID_PROPERTY_NAME)); return criteria.list(); } }; List objs = hibernate.executeFind(callback);
    public static boolean checkDuplicates(HibernateTemplate hibernate, BeanWithId obj,            String queryName, Object value, UserException exception) {        if (value == null) {            return false;        }                List objs = hibernate.findByNamedQueryAndNamedParam(queryName, "value", value);        return checkDuplicates(obj, objs, exception);    }