標籤:_id iter and dom main ret col 無法 arch
mybatis對text類型進行了特別處理,在selectByExampleWithBLOBs裡面,criteria裡面沒有。但可以自己在exampler裡面自己寫,他會自動對應成sql語句進行查詢
查詢代碼
List<OperatorLogDto> operatorLogDtos = new ArrayList<>();OperatorLogExample example = new OperatorLogExample();example.setOrderByClause("gmt_modify desc");example.createCriteria().andStatusEqualTo(2).andUserIdEqualTo(userId).andContentNotLike("%版本2.1%");List<OperatorLog> operatorLogs = operatorLogMapper.selectByExampleWithBLOBs(example);
產生的XXXExample類添加方法
public Criteria andContentLike(String value){addCriterion("content like", value, "content");return (Criteria) this;}public Criteria andContentNotLike(String value){addCriterion("content not like", value, "content");return (Criteria) this;}
XML
<resultMap id="BaseResultMap" type="com.beihui.domain.model.OperatorLog"> <id column="id" jdbcType="VARCHAR" property="id" /> <result column="user_id" jdbcType="VARCHAR" property="userId" /> <result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" /> <result column="gmt_modify" jdbcType="TIMESTAMP" property="gmtModify" /> <result column="ip" jdbcType="VARCHAR" property="ip" /> <result column="STATUS" jdbcType="INTEGER" property="status" /> <result column="methodName" jdbcType="VARCHAR" property="methodname" /></resultMap><resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.beihui.domain.model.OperatorLog"> <result column="content" jdbcType="LONGVARCHAR" property="content" /></resultMap>
mysql中欄位為text類型使用mybatis的Criteria查詢無法進行封裝