課程
/后端開(kāi)發(fā)
/Java
/基于SSH實(shí)現(xiàn)員工管理系統(tǒng)之案例實(shí)現(xiàn)篇
對(duì)于find方法 為什么老師的直接是Find(String,String,String),而我的必須要Find(String,object)呢??蚣馨姹镜膯?wèn)題嗎?
2017-03-11
源自:基于SSH實(shí)現(xiàn)員工管理系統(tǒng)之案例實(shí)現(xiàn)篇 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(); ????????????} ????????}); ????}
不懂,不過(guò)我可以給你另外一種find(String queryString,Object[] values)的方式,變成
this.getHibernateTemplate().find(hql,new String[]{employee.getUsername(),employee.getPassword()});
效果和this.getHibernateTemplate().find(hql, employee.getUsername(),employee.getPassword());是一樣的。
舉報(bào)
SSH框架整合案例之實(shí)現(xiàn)篇,手把手帶你實(shí)現(xiàn)員工管理系統(tǒng)
6 回答這里find方法報(bào)錯(cuò)
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 回答方法弄不懂
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢(xún)優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2017-03-28
2017-03-12
不懂,不過(guò)我可以給你另外一種find(String queryString,Object[] values)的方式,變成
this.getHibernateTemplate().find(hql,new String[]{employee.getUsername(),employee.getPassword()});
效果和this.getHibernateTemplate().find(hql, employee.getUsername(),employee.getPassword());是一樣的。