浏览 8936 次
锁定老帖子 主题: queryForMap的问题
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2008-11-26
queryForMap(statementName, parameterObject, keyProperty); 参数的含义 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2008-11-26
最后修改:2008-11-26
/**
* Executes a mapped SQL SELECT statement that returns data to populate * a number of result objects that will be keyed into a Map. * <p/> * The parameter object is generally used to supply the input * data for the WHERE clause parameter(s) of the SELECT statement. * * @param id The name of the statement to execute. * @param parameterObject The parameter object (e.g. JavaBean, Map, XML etc.). * @param keyProp The property to be used as the key in the Map. * @return A Map keyed by keyProp with values being the result object instance. */ 默认实现: public Map queryForMap(SessionScope session, String id, Object paramObject, String keyProp, String valueProp) throws SQLException { Map map = new HashMap(); List list = queryForList(session, id, paramObject); for (int i = 0, n = list.size(); i < n; i++) { Object object = list.get(i); Object key = PROBE.getObject(object, keyProp); Object value = null; if (valueProp == null) { value = object; } else { value = PROBE.getObject(object, valueProp); } map.put(key, value); } return map; } |
|
返回顶楼 | |
发表时间:2008-11-26
<select id="selectList" resultMap="selectHead"
parameterClass="java.lang.String"> select bill_id,bill_origin,bill_time,total,linkman_name,b.agentid,b.member_id ,paymentModeCodeName,a.agentName from etp_bills b,etp_linkmanbase l,paymentmode p ,agent a where b.linkman_id = l.linkman_id and b.payment_typeid = p.paymentModeId and b.agentid = a.agentId and bill_id = #bill_id# </select> <resultMap id="selectHead" class="com.bean.agent.AgentBean"> <result property="agentId" column="agentId" /> <result property="agentName" column="agentName" /> </resultMap> <resultMap id="selectHead" class="com.bean.agent.AgentBean"> <result property="linkman_id" column="linkman_id" /> <result property="linkman_name" column="linkman_name" /> </resultMap> <resultMap id="selectHead" class="com.bean.agent.AgentBean"> <result property="paymentModeCodeName" column="paymentModeCodeName" /> <result property="paymentModeId" column="paymentModeId" /> </resultMap> 比如我的配置文件是这样的 那 map = dao.queryForMap("selectList", billid, "selectHead");这样对吗 |
|
返回顶楼 | |