笔记1

public void execute(String hql) {
  baseDao.execute(hql);
 }

 

 

public void execute(String statement) {   execute(statement, new HashMap());  }

   

public void execute(final String statement, final Map paraMap) {

  getHibernateTemplate().execute(new HibernateCallback() {  

  public Object doInHibernate(Session session) throws HibernateException, SQLException {    

 Query query = session.createQuery(statement);     if (paraMap != null) {     

 query.setProperties(paraMap);   

  }   

  query.executeUpdate();    

 return null;    

}

  });

 }

 

 

 

public List query(final String queryString, final Map paraMap, final Integer firstResult, final Integer maxResults) {

  return getHibernateTemplate().executeFind(new HibernateCallback() {    

public Object doInHibernate(Session session) throws HibernateException, SQLException {    

 Query query = session.createQuery(queryString);    

 if (paraMap != null) {      

query.setProperties(paraMap);     }    

 if (firstResult != null) {      

query.setFirstResult(firstResult);     }   

  if (maxResults != null) {      

query.setMaxResults(maxResults);     }    

 return query.list();    }

  });  }

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(笔记)