setString(int position,String val)
引數說明:String hql = "from UserForm where sex=?"; //定義查詢HQL語句 Query query = session.createQuery(hql); //執行查詢語句,獲取Query物件 query.setString(0,"女"); //設定HQL語句引數
setString(String name,String val)
引數說明:String hql = "from UserForm where sex=:sex"; //定義查詢HQL語句 Query query = session.createQuery(hql); //執行查詢語句獲取Query物件 query.setString("sex","女"); //設定HQL語句引數