有时候为了简化我们的代码。
1 举个例子
Student类:
@Data
public class Student {
private Integer id;
private Integer age;
private Integer sno;
}
有时候我们想通过age这个属性获取Student对象
有时候我们也想通过sno这个属性获取Student对象
难道我们在DAO层写两个接口?
比如这样子?
Student getStudentByAge(Int age);
Student getStudentBySno(Int sno);
那么在mapper文件中要这样写?
<select id="getStudentByAge" parameterType="int" resultMap="studentMap">
select * from student where age=#{
age}
</select>
<select id="getStudentBySno" parameterType="int" resultMap="studentMap">
select * from student where sno=#{
sno}
</select>
显然,这样子是不高效的
2 上手测试 实验
实体类 Student:
@Data
public class Student {
@ApiModelProperty(name = "id",example = "1",position = 1)
private Integer id;
@ApiModelProperty(name = "age"