| | |
| | | |
| | | } |
| | | |
| | | |
| | | public void update(String hql, final Serializable[] params) { |
| | | hibernateTemplate.execute(new HibernateCallback() { |
| | | public Object doInHibernate(Session session) throws HibernateException { |
| | | Query query = session.createQuery(hql); |
| | | if (params != null) |
| | | for (int i = 0; i < params.length; i++) { |
| | | query.setParameter(i, params[i]); |
| | | } |
| | | query.executeUpdate(); |
| | | return null; |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | public List<T> list(String hql) { |
| | | return (List<T>) hibernateTemplate.find(hql); |
| | |
| | | String hql = "select count(*) " + hqlStr.substring(fromIndex); |
| | | |
| | | Query query = session.createQuery(hql); |
| | | for (int i = 0; i < wheres.length; i++) { |
| | | query.setParameter(i, wheres[i]); |
| | | } |
| | | if (wheres != null) |
| | | for (int i = 0; i < wheres.length; i++) { |
| | | query.setParameter(i, wheres[i]); |
| | | } |
| | | return Long.parseLong(query.uniqueResult() + ""); |
| | | } |
| | | }); |