MyBatis!将多个参数传递给Mapper DAO [英] MyBatis! Passing multiple parameter to Mapper DAO

查看:154
本文介绍了MyBatis!将多个参数传递给Mapper DAO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向DAO实现中定义的Mapper函数发送多个参数,但是在参数不属于任何类的情况下,无法发送多个参数. 我的意思是我该如何修改以下代码-

I am trying to send multiple parameter to Mapper function defined in DAO implementation but unable to send more than 1 parameter in the case when parameter are not holder of any class. I mean how can I modify the following code-

obj.getName(int a, int b);

在DAO实施中

public void getAllName() throws PersistenceException {
        SqlSession session = sf.openSession();
        try {
            session.selectList("getNames");         
        } finally {
            session.close();
        }
    }

我想发送a和b来查询getNames.

I want to send a and b to query getNames.

提前谢谢.

推荐答案

如果使用的是DAO实现,则可以使用HashMap来实现.只需在HashMap中添加键值对,然后将其添加到函数调用中,即可使用mapper.xml中访问它.

If you are using DAO implementation then you can do this by using a HashMap. Just add the key-value pair in HashMap and add it in function call and you can access it in the mapper.xml using "key".

这篇关于MyBatis!将多个参数传递给Mapper DAO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆