List of usage examples for org.hibernate Query setParameters
@Deprecated @SuppressWarnings("unchecked") default Query<R> setParameters(Object[] values, Type[] types)
From source file:sz.fcv.core.db.HQLExecuter.java
License:Open Source License
/** * Chiamata dalla classe figlia per eseguire una query hql * /*from w w w .ja va2s. co m*/ * @param hql * @param os * @param types */ public static void executeHQLUpdate(Session s, String hql, Object[] os, Type[] types) throws ConstraintViolationException, HibernateException, FileNotFoundException, IOException { Session session; if (s != null) { session = s; } else { session = createSession(); } Query q = session.createQuery(openSQLFile(hql)); q.setParameters(os, types); q.executeUpdate(); if (s == null) { commitSession(session); } }
From source file:sz.fcv.core.db.HQLExecuter.java
License:Open Source License
/** * /*from www . ja va2 s .co m*/ * @param hql * @param os * @param types */ public static void executeHQLDelete(Session s, String hql, Object[] os, Type[] types) throws HibernateException, FileNotFoundException, IOException { Session session; if (s != null) { session = s; } else { session = createSession(); } Query q = session.createQuery(openSQLFile(hql)); q.setParameters(os, types); q.executeUpdate(); if (s == null) { commitSession(session); } }
From source file:sz.fcv.core.db.HQLExecuter.java
License:Open Source License
/** * /* ww w . j a v a2s. c o m*/ * @param s * @param sql * @param os * @param types * @throws HibernateException * @throws FileNotFoundException * @throws IOException */ public static void executeSQLUpdate(Session s, String sql, Object[] os, Type[] types) throws HibernateException, FileNotFoundException, IOException { Session session; if (s != null) { session = s; } else { session = createSession(); } Query q = session.createSQLQuery(openSQLFile(sql)); q.setParameters(os, types); q.executeUpdate(); if (s == null) { commitSession(session); } }
From source file:wicket.contrib.phonebook.HibernateContactDao.java
License:Apache License
/** * builds a query object to satisfy the provided parameters * /* ww w. j ava 2s . com*/ * @param qp * sorting and paging criteria * @param filter * filter criteria * @param count * true if this is a query meant to retrieve the number of rows * @return query object that satisfies the provided criteria */ protected Query buildFindQuery(QueryParam qp, Contact filter, boolean count) { HibernateContactFinderQueryBuilder builder = new HibernateContactFinderQueryBuilder(); builder.setQueryParam(qp); builder.setFilter(filter); builder.setCount(count); Query query = getSession().createQuery(builder.buildHql()); query.setParameters(builder.getParameters(), builder.getTypes()); if (!count && qp != null) { query.setFirstResult((int) qp.getFirst()).setMaxResults((int) qp.getCount()); } return query; }