mybatis怎么设置两个parameterType
时间: 2023-12-29 07:05:49 浏览: 35
根据提供的引用内容,Mybatis的Mapper文件中的select、insert、update、delete元素中都有一个parameterType属性,用于对应的mapper接口方法接受的参数类型。因此,如果需要设置两个parameterType,可以考虑使用Map或者自定义对象作为参数类型,将需要传入的两个参数封装到Map或者自定义对象中,然后在Mapper文件中使用parameterType指定Map或者自定义对象的类型。例如:
```
public List<XXXBean> getXXXBeanList(Map<String, Object> paramMap);
<select id="getXXXBeanList" resultType="XXBean" parameterType="java.util.Map">
select t.* from tableName where id = #{id} and name = #{code}
</select>
```
或者自定义对象:
```
public class QueryParam {
private String id;
private String code;
// getter and setter
}
public List<XXXBean> getXXXBeanList(QueryParam queryParam);
<select id="getXXXBeanList" resultType="XXBean" parameterType="com.example.QueryParam">
select t.* from tableName where id = #{id} and name = #{code}
</select>
```
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)