List of usage examples for org.hibernate Session getNamedQuery
org.hibernate.Query getNamedQuery(String queryName);
From source file:com.adsapient.shared.dao.HibernateEntityDao.java
License:Open Source License
public Collection executeHQLQuery(final String queryName, final Map<String, Object> params) { List collect = (List) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { Query query = session.getNamedQuery(queryName); if ((params != null) && (params.size() > 0)) { for (String key : params.keySet()) query.setParameter(key, params.get(key)); }/*from ww w.ja v a 2s . c om*/ return query.list(); } }); return collect; }
From source file:com.agroservices.logic.PersistenceFacade.java
/** * Consulta el Id de las rutas que tiene que recorrer un transportista en determinada fecha * @param s Sesion de la base de datos// w ww . ja v a 2 s. c o m * @param t Transportista al que se le quiere consultar las rutas * @param d Fecha en la que se quieren consultar las rutas * @return Una lista con el Id de las rutas */ public static List<Integer> rutasPorTransportista(Session s, Transportista t, Date d) { //Query q2 = s.createQuery("SELECT r.idRutas FROM Ruta r WHERE r.fechaInicio=:fechaID AND r.transportistas.idTransportistas= :transportistaID"); Query q2 = s.getNamedQuery("rutaTransportista"); q2.setParameter("transportistaID", t.getIdTransportistas()); q2.setParameter("fechaID", d); List<Integer> rutas = q2.list(); return rutas; }
From source file:com.agroservices.logic.PersistenceFacade.java
/** * Consulta el nombre de los productos que tiene que recoger un transportista en determinada fecha * @param s Sesion de la base de datos/*from w w w. ja va 2 s . c o m*/ * @param t Transportista al que se le quiere consultar las rutas * @param d Fecha en la que se quieren consultar las rutas * @return Una lista con el nombre de las productos */ public static List<Integer> productosPorFecha(Session s, Transportista t, Date d) { /*Query q = s.createQuery("SELECT p.productos.nombre FROM ProductoEnVenta p WHERE p.idProductosEnVenta in " + "(SELECT d.detalleFactura.productosEnVenta.idProductosEnVenta FROM Despacho d WHERE d.rutas.transportistas.idTransportistas= :transportistaID AND d.rutas.fechaInicio=:fechaID)");*/ Query q = s.getNamedQuery("productosFecha"); q.setParameter("transportistaID", t.getIdTransportistas()); q.setParameter("fechaID", d); List<Integer> productos = q.list(); return productos; }
From source file:com.allinfinance.commquery.dao.CommQueryDAO.java
License:Open Source License
public List findByNamedQuery(final String name, final int begin, final int count) { return getHibernateTemplate().executeFind(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query query = session.getNamedQuery(name); if (begin >= 0) { query.setFirstResult(begin); query.setMaxResults(count); }/* www . j ava2 s . c o m*/ return query.list(); } }); }
From source file:com.allinfinance.commquery.dao.CommQueryDAO.java
License:Open Source License
public List findByNamedQuery(final String name, final Map params, final int begin, final int count) { return getHibernateTemplate().executeFind(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query query = session.getNamedQuery(name); if (null != params) { for (Iterator i = params.entrySet().iterator(); i.hasNext();) { Map.Entry entry = (Map.Entry) i.next(); query.setParameter((String) entry.getKey(), entry.getValue()); }/* ww w . j av a 2s .com*/ } if (begin >= 0) { query.setFirstResult(begin); query.setMaxResults(count); } return query.list(); } }); }
From source file:com.allinfinance.commquery.dao.CommQueryDAO.java
License:Open Source License
public List findByNamedQuery(final String name, final Serializable[] params, final int begin, final int count) { return getHibernateTemplate().executeFind(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Query query = session.getNamedQuery(name); if (null != params) { for (int i = 0; i < params.length; i++) { query.setParameter(i, params[i]); }// ww w . j a v a 2 s. c om } if (begin >= 0) { query.setFirstResult(begin); query.setMaxResults(count); } return query.list(); } }); }
From source file:com.anite.zebra.hivemind.om.state.ZebraProcessInstance.java
License:Apache License
/** * returns a list of all available tasks for the current user on this * process//from www. j a v a2 s. c om * * @return list of all available tasks for the current user on this process * @throws HibernateException */ @SuppressWarnings("unchecked") @Transient public List<ZebraTaskInstance> getUsersTasks() { Session session = RegistryHelper.getInstance().getSession(); ; Query tasks = session.getNamedQuery("tasks"); tasks.setParameter("processInstance", this); tasks.setParameter("showInTaskList", Boolean.TRUE); return tasks.list(); }
From source file:com.appeligo.alerts.KeywordAlert.java
License:Apache License
public static void deleteAllMarkedDeleted() { Permissions.checkUser(Permissions.SUPERUSER); Session session = getSession(); Query query = session.getNamedQuery("KeywordAlert.deleteAllMarkedDeleted"); query.executeUpdate();/* w w w.j a v a 2 s . c om*/ }
From source file:com.appeligo.alerts.KeywordAlert.java
License:Apache License
@SuppressWarnings("unchecked") public static KeywordAlert getByNormalizedQuery(User user, String query) { Permissions.checkUser(user);//from www . j a va 2 s.co m Session session = getSession(); Query hqlQuery = session.getNamedQuery("KeywordAlert.getByNormalizedQuery"); hqlQuery.setLong("userId", user.getUserId()); hqlQuery.setString("normalizedQuery", query); List<KeywordAlert> programAlerts = hqlQuery.list(); if (programAlerts.size() > 0) { return programAlerts.get(0); } else { return null; } }
From source file:com.appeligo.alerts.KeywordAlert.java
License:Apache License
public static ChunkedResults<KeywordAlert> getAllInNormalizedQueryOrder() { Permissions.checkUser(Permissions.SUPERUSER); Session session = getSession(); Query query = session.getNamedQuery("KeywordAlert.getAllInNormalizedQueryOrder"); query.setTimestamp("latestCreationTime", new Date()); return new ChunkedResults<KeywordAlert>(query); }