├── .gitignore ├── README.md ├── src ├── main │ ├── webapp │ │ ├── jsp │ │ │ └── index.jsp │ │ ├── error │ │ │ ├── 404.jsp │ │ │ ├── 405.jsp │ │ │ └── 500.jsp │ │ ├── index.jsp │ │ └── WEB-INF │ │ │ └── web.xml │ ├── resources │ │ ├── mybatis │ │ │ └── mybatis-config.xml │ │ ├── application.xml │ │ ├── log4j2.xml │ │ ├── properties │ │ │ └── database.properties │ │ ├── generatorConfig.xml │ │ ├── spring │ │ │ ├── spring-mvc.xml │ │ │ └── spring-mybatis.xml │ │ └── mapper │ │ │ └── UserMapper.xml │ └── java │ │ └── com │ │ └── demo │ │ ├── service │ │ └── UserService.java │ │ ├── bean │ │ ├── User.java │ │ └── UserExample.java │ │ ├── dao │ │ └── UserMapper.java │ │ ├── controller │ │ └── UserController.java │ │ └── serviceImpl │ │ └── UserServiceImpl.java └── test │ └── java │ └── com │ └── demo │ ├── service │ └── UserServiceTest.java │ ├── dao │ └── UserDaoTest.java │ ├── base │ └── SpringTestBase.java │ └── controller │ └── UserControllerTest.java └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /out 3 | /target 4 | /SSM.iml -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Spring-SpringMVC-MyBatis 2 | Spring+SpringMVC+MyBatis整合 3 | -------------------------------------------------------------------------------- /src/main/webapp/jsp/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | test 5 | 6 | 7 | 8 | JSP 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/main/webapp/error/404.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | 404 5 | 6 | 7 | 8 |

404

9 | 10 | 11 | -------------------------------------------------------------------------------- /src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | index 5 | 6 | 7 | 8 |

index

9 | 10 | 11 | -------------------------------------------------------------------------------- /src/main/webapp/error/405.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | 405 5 | 6 | 7 | 8 |

405

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/main/webapp/error/500.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | 500 5 | 6 | 7 | 8 |

500

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/main/resources/mybatis/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/main/java/com/demo/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.demo.service; 2 | 3 | import com.demo.bean.User; 4 | 5 | import java.util.List; 6 | 7 | public interface UserService { 8 | 9 | void insertUser(User user); 10 | 11 | void deleteUser(int id); 12 | 13 | User findUserById(Integer id); 14 | 15 | List findAllUsers(); 16 | 17 | void updateUser(User user); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/resources/application.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/resources/properties/database.properties: -------------------------------------------------------------------------------- 1 | db.driver=com.mysql.jdbc.Driver 2 | db.url=jdbc:mysql://localhost:3306/mybatis?characterEncoding=UTF-8 3 | db.user=root 4 | db.password=123456 5 | db.maxActive=10 6 | db.initialSize=2 7 | db.minIdle=2 8 | db.maxWait=60000 9 | db.timeBetweenEvictionRunsMillis=3000 10 | db.minEvictableIdleTimeMillis=300000 11 | db.validationQuery=SELECT 'x' FROM DUAL 12 | db.testWhileIdle=true 13 | db.testOnBorrow=false 14 | db.testOnReturn=false -------------------------------------------------------------------------------- /src/test/java/com/demo/service/UserServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.demo.service; 2 | 3 | import com.demo.base.SpringTestBase; 4 | import com.demo.bean.User; 5 | import org.junit.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | 8 | public class UserServiceTest extends SpringTestBase{ 9 | 10 | @Autowired 11 | private UserService userService; 12 | 13 | @Test 14 | public void findUserById() { 15 | User user = userService.findUserById(1); 16 | logger.info(user.toString()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/test/java/com/demo/dao/UserDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.demo.dao; 2 | 3 | import com.demo.base.SpringTestBase; 4 | import com.demo.bean.User; 5 | import org.junit.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | 8 | /** 9 | * Created by Administrator on 2017/3/19. 10 | */ 11 | public class UserDaoTest extends SpringTestBase { 12 | 13 | @Autowired 14 | private UserMapper userMapper; 15 | 16 | @Test 17 | public void selectUserByIdTest() { 18 | User user = userMapper.selectByPrimaryKey(1); 19 | logger.info(user.toString()); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/demo/bean/User.java: -------------------------------------------------------------------------------- 1 | package com.demo.bean; 2 | 3 | public class User { 4 | private Integer id; 5 | 6 | private String name; 7 | 8 | private String password; 9 | 10 | public Integer getId() { 11 | return id; 12 | } 13 | 14 | public void setId(Integer id) { 15 | this.id = id; 16 | } 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | public void setName(String name) { 23 | this.name = name == null ? null : name.trim(); 24 | } 25 | 26 | public String getPassword() { 27 | return password; 28 | } 29 | 30 | public void setPassword(String password) { 31 | this.password = password == null ? null : password.trim(); 32 | } 33 | } -------------------------------------------------------------------------------- /src/test/java/com/demo/base/SpringTestBase.java: -------------------------------------------------------------------------------- 1 | package com.demo.base; 2 | 3 | import org.apache.logging.log4j.LogManager; 4 | import org.apache.logging.log4j.Logger; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.test.context.ContextConfiguration; 7 | import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; 8 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 9 | import org.springframework.test.context.web.WebAppConfiguration; 10 | 11 | @WebAppConfiguration 12 | @RunWith(SpringJUnit4ClassRunner.class) 13 | @ContextConfiguration(locations = {"classpath:application.xml","classpath:spring/spring-mvc.xml"}) 14 | public class SpringTestBase extends AbstractJUnit4SpringContextTests { 15 | 16 | protected static Logger logger = LogManager.getLogger(); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/demo/dao/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.demo.dao; 2 | 3 | import com.demo.bean.User; 4 | import com.demo.bean.UserExample; 5 | import java.util.List; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | public interface UserMapper { 9 | long countByExample(UserExample example); 10 | 11 | int deleteByExample(UserExample example); 12 | 13 | int deleteByPrimaryKey(Integer id); 14 | 15 | int insert(User record); 16 | 17 | int insertSelective(User record); 18 | 19 | List selectByExample(UserExample example); 20 | 21 | User selectByPrimaryKey(Integer id); 22 | 23 | int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example); 24 | 25 | int updateByExample(@Param("record") User record, @Param("example") UserExample example); 26 | 27 | int updateByPrimaryKeySelective(User record); 28 | 29 | int updateByPrimaryKey(User record); 30 | } -------------------------------------------------------------------------------- /src/main/java/com/demo/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.demo.controller; 2 | 3 | import com.demo.bean.User; 4 | import com.demo.service.UserService; 5 | import org.apache.logging.log4j.LogManager; 6 | import org.apache.logging.log4j.Logger; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | import org.springframework.web.bind.annotation.ResponseBody; 13 | 14 | @Controller 15 | @RequestMapping(value = "/user") 16 | public class UserController { 17 | 18 | private static Logger logger = LogManager.getLogger(); 19 | 20 | @Autowired 21 | private UserService userService; 22 | 23 | @RequestMapping(value = "/{id}", method = RequestMethod.GET) 24 | @ResponseBody 25 | public User findUserById(@PathVariable("id") Integer id) { 26 | User user = userService.findUserById(id); 27 | logger.info(user.toString()); 28 | return user; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/demo/serviceImpl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.demo.serviceImpl; 2 | 3 | import com.demo.bean.User; 4 | import com.demo.bean.UserExample; 5 | import com.demo.dao.UserMapper; 6 | import com.demo.service.UserService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.List; 11 | 12 | @Service 13 | public class UserServiceImpl implements UserService { 14 | 15 | @Autowired 16 | private UserMapper userMapper; 17 | 18 | @Override 19 | public void insertUser(User user) { 20 | userMapper.insert(user); 21 | } 22 | 23 | @Override 24 | public void deleteUser(int id) { 25 | UserExample userExample = new UserExample(); 26 | userExample.createCriteria().andIdEqualTo(id); 27 | userMapper.deleteByExample(userExample); 28 | } 29 | 30 | @Override 31 | public User findUserById(Integer id) { 32 | return userMapper.selectByPrimaryKey(id); 33 | } 34 | 35 | @Override 36 | public List findAllUsers() { 37 | return userMapper.selectByExample(null); 38 | } 39 | 40 | @Override 41 | public void updateUser(User user) { 42 | userMapper.updateByPrimaryKey(user); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/com/demo/controller/UserControllerTest.java: -------------------------------------------------------------------------------- 1 | package com.demo.controller; 2 | 3 | import com.demo.base.SpringTestBase; 4 | import org.junit.Before; 5 | import org.junit.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.test.web.servlet.MockMvc; 8 | import org.springframework.test.web.servlet.MvcResult; 9 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; 10 | import org.springframework.test.web.servlet.setup.MockMvcBuilders; 11 | 12 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 13 | 14 | /** 15 | * Created by Administrator on 2017/3/18. 16 | */ 17 | public class UserControllerTest extends SpringTestBase { 18 | 19 | private MockMvc mockMvc; 20 | 21 | @Autowired 22 | private UserController userController; 23 | 24 | @Before 25 | public void setup() throws Exception { 26 | mockMvc = MockMvcBuilders.standaloneSetup(userController).build(); 27 | } 28 | 29 | @Test 30 | public void controllerExceptionHandler() throws Exception { 31 | MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/user/1")) 32 | .andExpect(status().isOk()) 33 | .andReturn(); 34 | String result = mvcResult.getResponse().getContentAsString(); 35 | logger.info("result==" + result); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/resources/generatorConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/main/resources/spring/spring-mvc.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | index.jsp 10 | 11 | 12 | 13 | 14 | 15 | 404 16 | /error/404.jsp 17 | 18 | 19 | 20 | 21 | 405 22 | /error/405.jsp 23 | 24 | 25 | 26 | 27 | 500 28 | /error/500.jsp 29 | 30 | 31 | 32 | contextConfigLocation 33 | classpath:application.xml 34 | 35 | 36 | 37 | 38 | SpringEncodingFilter 39 | org.springframework.web.filter.CharacterEncodingFilter 40 | 41 | encoding 42 | UTF-8 43 | 44 | 45 | forceEncoding 46 | true 47 | 48 | 49 | 50 | 51 | SpringEncodingFilter 52 | /* 53 | 54 | 55 | 56 | org.springframework.web.context.ContextLoaderListener 57 | 58 | 59 | 60 | dispatcher 61 | org.springframework.web.servlet.DispatcherServlet 62 | 63 | contextConfigLocation 64 | classpath:spring/spring-mvc.xml 65 | 66 | 1 67 | 68 | 69 | 70 | dispatcher 71 | / 72 | 73 | 74 | -------------------------------------------------------------------------------- /src/main/resources/spring/spring-mybatis.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.demo 8 | SSM 9 | 1.0-SNAPSHOT 10 | war 11 | SSM 12 | 13 | 14 | 15 | 4.3.4.RELEASE 16 | 3.4.2 17 | 2.7 18 | 4.12 19 | 5.1.40 20 | 21 | 22 | 23 | 24 | 25 | org.springframework 26 | spring-core 27 | ${spring.version} 28 | 29 | 30 | 31 | org.springframework 32 | spring-context 33 | ${spring.version} 34 | 35 | 36 | 37 | org.springframework 38 | spring-web 39 | ${spring.version} 40 | 41 | 42 | 43 | org.springframework 44 | spring-webmvc 45 | ${spring.version} 46 | 47 | 48 | 49 | org.springframework 50 | spring-jdbc 51 | ${spring.version} 52 | 53 | 54 | 55 | 56 | org.springframework 57 | spring-oxm 58 | ${spring.version} 59 | 60 | 61 | 62 | org.springframework 63 | spring-test 64 | ${spring.version} 65 | 66 | 67 | 68 | org.springframework 69 | spring-context-support 70 | ${spring.version} 71 | 72 | 73 | 74 | org.springframework 75 | spring-aspects 76 | ${spring.version} 77 | 78 | 79 | 80 | 81 | 82 | aopalliance 83 | aopalliance 84 | 1.0 85 | 86 | 87 | 88 | org.aspectj 89 | aspectjweaver 90 | 1.8.10 91 | 92 | 93 | 94 | 95 | 96 | commons-fileupload 97 | commons-fileupload 98 | 1.3.2 99 | 100 | 101 | 102 | 103 | 104 | com.fasterxml.jackson.core 105 | jackson-core 106 | 2.8.4 107 | 108 | 109 | 110 | com.fasterxml.jackson.core 111 | jackson-databind 112 | 2.8.4 113 | 114 | 115 | 116 | 117 | 118 | org.mybatis 119 | mybatis 120 | 3.4.2 121 | 122 | 123 | 124 | org.mybatis 125 | mybatis-spring 126 | 1.3.1 127 | 128 | 129 | 130 | 131 | 132 | org.apache.logging.log4j 133 | log4j-core 134 | ${log4j.version} 135 | 136 | 137 | 138 | 139 | 140 | junit 141 | junit 142 | ${junit.version} 143 | 144 | 145 | 146 | 147 | 148 | mysql 149 | mysql-connector-java 150 | 5.1.40 151 | 152 | 153 | 154 | 155 | 156 | com.alibaba 157 | druid 158 | 1.0.29 159 | 160 | 161 | 162 | 163 | javax.servlet 164 | javax.servlet-api 165 | 4.0.1 166 | provided 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | org.apache.maven.plugins 175 | maven-compiler-plugin 176 | 3.6.1 177 | 178 | 1.8 179 | 1.8 180 | 181 | 182 | 183 | 184 | 185 | org.mybatis.generator 186 | mybatis-generator-maven-plugin 187 | 1.3.5 188 | 189 | true 190 | true 191 | 192 | 193 | 194 | 195 | 196 | -------------------------------------------------------------------------------- /src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | and ${criterion.condition} 18 | 19 | 20 | and ${criterion.condition} #{criterion.value} 21 | 22 | 23 | and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} 24 | 25 | 26 | and ${criterion.condition} 27 | 28 | #{listItem} 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | and ${criterion.condition} 47 | 48 | 49 | and ${criterion.condition} #{criterion.value} 50 | 51 | 52 | and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} 53 | 54 | 55 | and ${criterion.condition} 56 | 57 | #{listItem} 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | id, name, password 69 | 70 | 84 | 90 | 91 | delete from user 92 | where id = #{id,jdbcType=INTEGER} 93 | 94 | 95 | delete from user 96 | 97 | 98 | 99 | 100 | 101 | insert into user (id, name, password) 102 | values (#{id,jdbcType=INTEGER}, #{name,jdbcType=CHAR}, #{password,jdbcType=CHAR}) 103 | 104 | 105 | insert into user 106 | 107 | 108 | id, 109 | 110 | 111 | name, 112 | 113 | 114 | password, 115 | 116 | 117 | 118 | 119 | #{id,jdbcType=INTEGER}, 120 | 121 | 122 | #{name,jdbcType=CHAR}, 123 | 124 | 125 | #{password,jdbcType=CHAR}, 126 | 127 | 128 | 129 | 135 | 136 | update user 137 | 138 | 139 | id = #{record.id,jdbcType=INTEGER}, 140 | 141 | 142 | name = #{record.name,jdbcType=CHAR}, 143 | 144 | 145 | password = #{record.password,jdbcType=CHAR}, 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | update user 154 | set id = #{record.id,jdbcType=INTEGER}, 155 | name = #{record.name,jdbcType=CHAR}, 156 | password = #{record.password,jdbcType=CHAR} 157 | 158 | 159 | 160 | 161 | 162 | update user 163 | 164 | 165 | name = #{name,jdbcType=CHAR}, 166 | 167 | 168 | password = #{password,jdbcType=CHAR}, 169 | 170 | 171 | where id = #{id,jdbcType=INTEGER} 172 | 173 | 174 | update user 175 | set name = #{name,jdbcType=CHAR}, 176 | password = #{password,jdbcType=CHAR} 177 | where id = #{id,jdbcType=INTEGER} 178 | 179 | -------------------------------------------------------------------------------- /src/main/java/com/demo/bean/UserExample.java: -------------------------------------------------------------------------------- 1 | package com.demo.bean; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class UserExample { 7 | protected String orderByClause; 8 | 9 | protected boolean distinct; 10 | 11 | protected List oredCriteria; 12 | 13 | public UserExample() { 14 | oredCriteria = new ArrayList(); 15 | } 16 | 17 | public void setOrderByClause(String orderByClause) { 18 | this.orderByClause = orderByClause; 19 | } 20 | 21 | public String getOrderByClause() { 22 | return orderByClause; 23 | } 24 | 25 | public void setDistinct(boolean distinct) { 26 | this.distinct = distinct; 27 | } 28 | 29 | public boolean isDistinct() { 30 | return distinct; 31 | } 32 | 33 | public List getOredCriteria() { 34 | return oredCriteria; 35 | } 36 | 37 | public void or(Criteria criteria) { 38 | oredCriteria.add(criteria); 39 | } 40 | 41 | public Criteria or() { 42 | Criteria criteria = createCriteriaInternal(); 43 | oredCriteria.add(criteria); 44 | return criteria; 45 | } 46 | 47 | public Criteria createCriteria() { 48 | Criteria criteria = createCriteriaInternal(); 49 | if (oredCriteria.size() == 0) { 50 | oredCriteria.add(criteria); 51 | } 52 | return criteria; 53 | } 54 | 55 | protected Criteria createCriteriaInternal() { 56 | Criteria criteria = new Criteria(); 57 | return criteria; 58 | } 59 | 60 | public void clear() { 61 | oredCriteria.clear(); 62 | orderByClause = null; 63 | distinct = false; 64 | } 65 | 66 | protected abstract static class GeneratedCriteria { 67 | protected List criteria; 68 | 69 | protected GeneratedCriteria() { 70 | super(); 71 | criteria = new ArrayList(); 72 | } 73 | 74 | public boolean isValid() { 75 | return criteria.size() > 0; 76 | } 77 | 78 | public List getAllCriteria() { 79 | return criteria; 80 | } 81 | 82 | public List getCriteria() { 83 | return criteria; 84 | } 85 | 86 | protected void addCriterion(String condition) { 87 | if (condition == null) { 88 | throw new RuntimeException("Value for condition cannot be null"); 89 | } 90 | criteria.add(new Criterion(condition)); 91 | } 92 | 93 | protected void addCriterion(String condition, Object value, String property) { 94 | if (value == null) { 95 | throw new RuntimeException("Value for " + property + " cannot be null"); 96 | } 97 | criteria.add(new Criterion(condition, value)); 98 | } 99 | 100 | protected void addCriterion(String condition, Object value1, Object value2, String property) { 101 | if (value1 == null || value2 == null) { 102 | throw new RuntimeException("Between values for " + property + " cannot be null"); 103 | } 104 | criteria.add(new Criterion(condition, value1, value2)); 105 | } 106 | 107 | public Criteria andIdIsNull() { 108 | addCriterion("id is null"); 109 | return (Criteria) this; 110 | } 111 | 112 | public Criteria andIdIsNotNull() { 113 | addCriterion("id is not null"); 114 | return (Criteria) this; 115 | } 116 | 117 | public Criteria andIdEqualTo(Integer value) { 118 | addCriterion("id =", value, "id"); 119 | return (Criteria) this; 120 | } 121 | 122 | public Criteria andIdNotEqualTo(Integer value) { 123 | addCriterion("id <>", value, "id"); 124 | return (Criteria) this; 125 | } 126 | 127 | public Criteria andIdGreaterThan(Integer value) { 128 | addCriterion("id >", value, "id"); 129 | return (Criteria) this; 130 | } 131 | 132 | public Criteria andIdGreaterThanOrEqualTo(Integer value) { 133 | addCriterion("id >=", value, "id"); 134 | return (Criteria) this; 135 | } 136 | 137 | public Criteria andIdLessThan(Integer value) { 138 | addCriterion("id <", value, "id"); 139 | return (Criteria) this; 140 | } 141 | 142 | public Criteria andIdLessThanOrEqualTo(Integer value) { 143 | addCriterion("id <=", value, "id"); 144 | return (Criteria) this; 145 | } 146 | 147 | public Criteria andIdIn(List values) { 148 | addCriterion("id in", values, "id"); 149 | return (Criteria) this; 150 | } 151 | 152 | public Criteria andIdNotIn(List values) { 153 | addCriterion("id not in", values, "id"); 154 | return (Criteria) this; 155 | } 156 | 157 | public Criteria andIdBetween(Integer value1, Integer value2) { 158 | addCriterion("id between", value1, value2, "id"); 159 | return (Criteria) this; 160 | } 161 | 162 | public Criteria andIdNotBetween(Integer value1, Integer value2) { 163 | addCriterion("id not between", value1, value2, "id"); 164 | return (Criteria) this; 165 | } 166 | 167 | public Criteria andNameIsNull() { 168 | addCriterion("name is null"); 169 | return (Criteria) this; 170 | } 171 | 172 | public Criteria andNameIsNotNull() { 173 | addCriterion("name is not null"); 174 | return (Criteria) this; 175 | } 176 | 177 | public Criteria andNameEqualTo(String value) { 178 | addCriterion("name =", value, "name"); 179 | return (Criteria) this; 180 | } 181 | 182 | public Criteria andNameNotEqualTo(String value) { 183 | addCriterion("name <>", value, "name"); 184 | return (Criteria) this; 185 | } 186 | 187 | public Criteria andNameGreaterThan(String value) { 188 | addCriterion("name >", value, "name"); 189 | return (Criteria) this; 190 | } 191 | 192 | public Criteria andNameGreaterThanOrEqualTo(String value) { 193 | addCriterion("name >=", value, "name"); 194 | return (Criteria) this; 195 | } 196 | 197 | public Criteria andNameLessThan(String value) { 198 | addCriterion("name <", value, "name"); 199 | return (Criteria) this; 200 | } 201 | 202 | public Criteria andNameLessThanOrEqualTo(String value) { 203 | addCriterion("name <=", value, "name"); 204 | return (Criteria) this; 205 | } 206 | 207 | public Criteria andNameLike(String value) { 208 | addCriterion("name like", value, "name"); 209 | return (Criteria) this; 210 | } 211 | 212 | public Criteria andNameNotLike(String value) { 213 | addCriterion("name not like", value, "name"); 214 | return (Criteria) this; 215 | } 216 | 217 | public Criteria andNameIn(List values) { 218 | addCriterion("name in", values, "name"); 219 | return (Criteria) this; 220 | } 221 | 222 | public Criteria andNameNotIn(List values) { 223 | addCriterion("name not in", values, "name"); 224 | return (Criteria) this; 225 | } 226 | 227 | public Criteria andNameBetween(String value1, String value2) { 228 | addCriterion("name between", value1, value2, "name"); 229 | return (Criteria) this; 230 | } 231 | 232 | public Criteria andNameNotBetween(String value1, String value2) { 233 | addCriterion("name not between", value1, value2, "name"); 234 | return (Criteria) this; 235 | } 236 | 237 | public Criteria andPasswordIsNull() { 238 | addCriterion("password is null"); 239 | return (Criteria) this; 240 | } 241 | 242 | public Criteria andPasswordIsNotNull() { 243 | addCriterion("password is not null"); 244 | return (Criteria) this; 245 | } 246 | 247 | public Criteria andPasswordEqualTo(String value) { 248 | addCriterion("password =", value, "password"); 249 | return (Criteria) this; 250 | } 251 | 252 | public Criteria andPasswordNotEqualTo(String value) { 253 | addCriterion("password <>", value, "password"); 254 | return (Criteria) this; 255 | } 256 | 257 | public Criteria andPasswordGreaterThan(String value) { 258 | addCriterion("password >", value, "password"); 259 | return (Criteria) this; 260 | } 261 | 262 | public Criteria andPasswordGreaterThanOrEqualTo(String value) { 263 | addCriterion("password >=", value, "password"); 264 | return (Criteria) this; 265 | } 266 | 267 | public Criteria andPasswordLessThan(String value) { 268 | addCriterion("password <", value, "password"); 269 | return (Criteria) this; 270 | } 271 | 272 | public Criteria andPasswordLessThanOrEqualTo(String value) { 273 | addCriterion("password <=", value, "password"); 274 | return (Criteria) this; 275 | } 276 | 277 | public Criteria andPasswordLike(String value) { 278 | addCriterion("password like", value, "password"); 279 | return (Criteria) this; 280 | } 281 | 282 | public Criteria andPasswordNotLike(String value) { 283 | addCriterion("password not like", value, "password"); 284 | return (Criteria) this; 285 | } 286 | 287 | public Criteria andPasswordIn(List values) { 288 | addCriterion("password in", values, "password"); 289 | return (Criteria) this; 290 | } 291 | 292 | public Criteria andPasswordNotIn(List values) { 293 | addCriterion("password not in", values, "password"); 294 | return (Criteria) this; 295 | } 296 | 297 | public Criteria andPasswordBetween(String value1, String value2) { 298 | addCriterion("password between", value1, value2, "password"); 299 | return (Criteria) this; 300 | } 301 | 302 | public Criteria andPasswordNotBetween(String value1, String value2) { 303 | addCriterion("password not between", value1, value2, "password"); 304 | return (Criteria) this; 305 | } 306 | } 307 | 308 | public static class Criteria extends GeneratedCriteria { 309 | 310 | protected Criteria() { 311 | super(); 312 | } 313 | } 314 | 315 | public static class Criterion { 316 | private String condition; 317 | 318 | private Object value; 319 | 320 | private Object secondValue; 321 | 322 | private boolean noValue; 323 | 324 | private boolean singleValue; 325 | 326 | private boolean betweenValue; 327 | 328 | private boolean listValue; 329 | 330 | private String typeHandler; 331 | 332 | public String getCondition() { 333 | return condition; 334 | } 335 | 336 | public Object getValue() { 337 | return value; 338 | } 339 | 340 | public Object getSecondValue() { 341 | return secondValue; 342 | } 343 | 344 | public boolean isNoValue() { 345 | return noValue; 346 | } 347 | 348 | public boolean isSingleValue() { 349 | return singleValue; 350 | } 351 | 352 | public boolean isBetweenValue() { 353 | return betweenValue; 354 | } 355 | 356 | public boolean isListValue() { 357 | return listValue; 358 | } 359 | 360 | public String getTypeHandler() { 361 | return typeHandler; 362 | } 363 | 364 | protected Criterion(String condition) { 365 | super(); 366 | this.condition = condition; 367 | this.typeHandler = null; 368 | this.noValue = true; 369 | } 370 | 371 | protected Criterion(String condition, Object value, String typeHandler) { 372 | super(); 373 | this.condition = condition; 374 | this.value = value; 375 | this.typeHandler = typeHandler; 376 | if (value instanceof List) { 377 | this.listValue = true; 378 | } else { 379 | this.singleValue = true; 380 | } 381 | } 382 | 383 | protected Criterion(String condition, Object value) { 384 | this(condition, value, null); 385 | } 386 | 387 | protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { 388 | super(); 389 | this.condition = condition; 390 | this.value = value; 391 | this.secondValue = secondValue; 392 | this.typeHandler = typeHandler; 393 | this.betweenValue = true; 394 | } 395 | 396 | protected Criterion(String condition, Object value, Object secondValue) { 397 | this(condition, value, secondValue, null); 398 | } 399 | } 400 | } --------------------------------------------------------------------------------