💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# parameterType参数类型 1. 简单的类型 2. POJO对象(OGNL表达式) QueryVo ```java package com.gosuncn.dao; import com.gosuncn.entity.User; public interface UserMapper { User findUserByVo(QueryVo vo); } ``` ```java package com.gosuncn.dao; import com.gosuncn.entity.User; public class QueryVo { private User user; public User getUser() { return user; } public void setUser(User user) { this.user = user; } } ``` ```xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.gosuncn.dao.UserMapper"> <select id="findUserByVo" parameterType="com.gosuncn.dao.QueryVo" resultType="com.gosuncn.entity.User"> select id, name, age, address from user where name like #{user.name} </select> </mapper> ``` ```java package com.gosuncn; import com.gosuncn.dao.QueryVo; import com.gosuncn.dao.UserMapper; import com.gosuncn.entity.User; import org.apache.ibatis.io.Resources; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactoryBuilder; import java.io.InputStream; public class MainTest { public static void main(String[] args) throws Exception { InputStream inputStream = Resources.getResourceAsStream("SqlMapConfig.xml"); SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(inputStream); SqlSession sqlSession = sessionFactory.openSession(); UserMapper userMapper = sqlSession.getMapper(UserMapper.class); QueryVo vo = new QueryVo(); User user = new User(); user.setName("%poll%"); vo.setUser(user); System.out.println(userMapper.findUserByVo(vo)); sqlSession.close(); inputStream.close(); } } ```