1.mybatis判断是否为空或null <if test="type!=null and type!=''"> AND type = #{type} </if> 2.Mybatis中的like查询 今天要做一个模糊查询 用的Mybatis 开始写的是: select id,bookName,author,publisher,donor,status,createDate,lastUpdate from book <where> <if tes
我们发现我们可以通过传入javaBean的方式实现我们的需求,但是就两个条件,思考:现在就给他传入一个实体类,对系统性能的开销是不是有点大了. 现在改用传入Map集合的方式: 奥!对了,在创建map集合时候,居然报错了,The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class. 是因为myeclipse的jdk和你安装的jdk的版本不一致导致的,只要将两者调成
零:sql动态语句中经常会有根据数据库某个字段状态进行判断的 如:status=0为未激活,status=1为激活的,那搜索未激活时: <if test="model.activeStatus != null and model.activeStatus !='' or model.activeStatus==0"> and status=#{model.activeStatus} </if> 但由于java的int类型默认值为0,导致0与null的判定无法识别
一对多写了mapper映射之后 根据条件查条数 可以根据主表的唯一id进行分组 在拿到它的count select count(0) over(aa.id),,id,name,age from tab1 aa left join tab2 bb on aa.id = bb.id group by aa.id
<select id="getAllDitch" parameterType="xxx.xx.entity.CheckDitch" resultType="xxx.xx.entity.CheckDitch"> select <include refid="checkDitchColumns"/> from check_ditch a <where> a.status not in (-1)
1.Map中根据字段名存儲: 定义接口:List<Student> selectByCondition1(Map<String,Object> map); 映射文件: <select id="selectByCondition1" resultType="com.framework.entity.Student"> select * from stu where name like '%' #{name} '%' and age