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);
In DAO implementation
public void getAllName() throws PersistenceException {
SqlSession session = sf.openSession();
try {
session.selectList("getNames");
} finally {
session.close();
}
}
I want to send a and b to query getNames.
Thanks in advance.
解决方案
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".