課程
/后端開發
/Java
/基于SSH實現員工管理系統之案例實現篇
對于find方法 為什么老師的直接是Find(String,String,String),而我的必須要Find(String,object)呢。框架版本的問題嗎?
2017-03-11
源自:基于SSH實現員工管理系統之案例實現篇 2-2
正在回答
Hibernate5?里面HibernateTemplateClass里的find源碼 (選中find按F3即可看到) @Override ????public?List<?>?find(final?String?queryString,?final?Object...?values)?throws?DataAccessException?{ ????????return?executeWithNativeSession(new?HibernateCallback<List<?>>()?{ ????????????@Override ????????????@SuppressWarnings({"rawtypes",?"deprecation"}) ????????????public?List<?>?doInHibernate(Session?session)?throws?HibernateException?{ ????????????????org.hibernate.Query?queryObject?=?(org.hibernate.Query) ????????????????????????ReflectionUtils.invokeMethod(createQueryMethod,?session,?queryString); ????????????????prepareQuery(queryObject); ????????????????if?(values?!=?null)?{ ????????????????????for?(int?i?=?0;?i?<?values.length;?i++)?{ ????????????????????????queryObject.setParameter(i,?values[i]); ????????????????????} ????????????????} ????????????????return?queryObject.list(); ????????????} ????????}); ????}
不懂,不過我可以給你另外一種find(String queryString,Object[] values)的方式,變成
this.getHibernateTemplate().find(hql,new String[]{employee.getUsername(),employee.getPassword()});
效果和this.getHibernateTemplate().find(hql, employee.getUsername(),employee.getPassword());是一樣的。
舉報
SSH框架整合案例之實現篇,手把手帶你實現員工管理系統
6 回答這里find方法報錯
1 回答his.getHibernateTemplate().find(hql)和list.get(0)
3 回答Cannot find class [com.mchange.v2.c3p0.ComboPolledDataSource]
1 回答this.getHibernateTemplate().find(hql,employee.getUsername(),employee.getPassword());為空
1 回答find這里應該怎么寫
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2017-03-28
2017-03-12
不懂,不過我可以給你另外一種find(String queryString,Object[] values)的方式,變成
this.getHibernateTemplate().find(hql,new String[]{employee.getUsername(),employee.getPassword()});
效果和this.getHibernateTemplate().find(hql, employee.getUsername(),employee.getPassword());是一樣的。