mybatis中@Select等注解的使用
1.@Select查询中concat用于mysql字符串拼接,<script></script>内可以使用mybatis的标签。
2.@Results 说明返回对象集合。内部是返回对象和数据库字段的映射规则。
@Select({
"<script>select",
"a.id as id,a.name as name,a.telephone as telephone ,a.updates as updates ,",
"a.types as types ,a.levels as levels ,a.creator as creator ,a.address as address ,",
"a.details as details ,a.cardid as cardid ,b.xh as xh,b.comes as comes",
"from custom a left join origin b",
"on a.id=b.kid",
"where 1=1 <when test='first !=null and first != \"\" '> and a.name like concat('%',#{first},'%') </when>",
"<when test='second !=null and second != \"\" '> and a.telephone like concat('%',#{second},'%') </when>",
"<when test='third !=null and third != \"\" '> and a.levels = #{third} </when>",
"<when test='fourth !=null and fourth != \"\" '> and b.comes = #{fourth} </when></script>"
})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
@Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
@Result(column="telephone", property="telephone", jdbcType=JdbcType.VARCHAR),
@Result(column="updates", property="updates", jdbcType=JdbcType.TIMESTAMP),
@Result(column="types", property="types", jdbcType=JdbcType.VARCHAR),
@Result(column="levels", property="levels", jdbcType=JdbcType.VARCHAR),
@Result(column="creator", property="creator", jdbcType=JdbcType.VARCHAR),
@Result(column="address", property="address", jdbcType=JdbcType.VARCHAR),
@Result(column="details", property="details", jdbcType=JdbcType.VARCHAR),
@Result(column="cardid", property="cardid", jdbcType=JdbcType.VARCHAR),
@Result(column="xh", property="xh", jdbcType=JdbcType.INTEGER),
@Result(column="comes", property="comes", jdbcType=JdbcType.VARCHAR)
})
List<DetailVO> selectByUnion(@Param("first") String first , @Param("second") String second ,@Param("third") String third ,
@Param("fourth")String fourth);
版权声明:本文为weixin_42434063原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。