hib 传参数


String   hqlDelete   =   "delete   EaccountForm   where   serial_no_ecustomer   =   :serial_no_ecustomer   ";  
                  int   deletedEntities   =   session.createQuery(   hqlDelete   )  
                                                          .setString(   "serial_no_ecustomer",   serial_no_ecustomer   )                                                        
                                                          .executeUpdate();
                                                         
                                                         
//以条件来区分的  
  String   hql="delete   from   User   where   age   <   18   ";  
  session.createQuery(hql).executeUpdate();  
   
  //多个ID的  
  String   hql="delete   form   User   where   id   in   :idd";  
  session.createQuery(hql).setParameterList("idd",idd_list).executeUpdate();       
 

 

Object[] obj={"%"+typeName+"%",new Integer(flgDelete)};
return (List) getHibernateTemplate().find("from Type t where t.name like ? and t.flgDelete=?",obj);

 

con = HibernateConnectionManager.getConnection();
            //SELECT id FROM SYS_USER WHERE (group_id = ? OR '0' = ?) AND (logon_id LIKE ? OR NAME LIKE ?) ORDER BY priority
            pstmt = con.prepareStatement(QUERY_USER);
            pstmt.setString(1, groupID);
            pstmt.setString(2, groupID);
            pstmt.setString(3, "%" + key + "%");
            pstmt.setString(4, "%" + key + "%");

 

public List<Dictionary> search(Map<String, String[]> param) {
  String hql = "from Dictionary as dic where dic.name like :name and dic.code like :code ";
  Map<String, Object> paramsM = new HashMap();
  //字典字典码
  String code = getParameter(param, "code");
  paramsM.put("code", code==null?"":("%"+code+"%"));  
  //字典名称
  String name = getParameter(param, "name");
  paramsM.put("name", name==null?"":("%"+name+"%"));         

 

select * from oa_org_action_uims
where action_time >= to_date('2007-9-4 17:15:39','yyyy_mm_dd HH24:MI:SS')

 

 Query updateQuery=this.getSession().createQuery(hql.toString());
  updateQuery.setString(0, researchId);
  updateQuery.setString(1, researchId);
  
  updateQuery.executeUpdate();

 

StringBuffer hql = new StringBuffer(
    "delete from SampleLibTempAddResult s where s.sampleid in(:ids) and s.batchid=:batchid ");
  
  Query updateQuery=this.getSession().createQuery(hql.toString());
  
  updateQuery.setParameterList("ids", ids);
  updateQuery.setParameter("batchid", batchId, Hibernate.STRING);
  updateQuery.executeUpdate();

posted @ 2013-05-03 09:16  rattersnake  阅读(205)  评论(0编辑  收藏  举报