mybatis中的updateByExampleSelective方法怎麼使用

mybatis中的updateByExampleSelective方法怎麼使用。
sendDetailMapper.updateByExampleSelective(sendDetail, m);
參數m怎麼傳mybatis

這個問題的方法是 mybatis-generator 生成的模板方法。app

updateByExampleSelective(@Param("record") Xxx record, @Param("example") XxxExample example);spa

第一個參數 是要修改的部分值組成的對象,其中有些屬性爲null則表示該項不修改。code

第二個參數 是一個對應的查詢條件的類, 經過這個類能夠實現 order by 和一部分的where 條件。對象

使用方法大概以下:get

 
XxxExample example = new XxxExample(); Criteria criteria = example.createCriteria(); // 這個內部類中有對應Xxx的每一個屬性的條件方法 . // 假如 Xxx 包含id 屬性. // 那它就有 andId(屬性)EqualTo(SQL裏的各類標準條件語句, =、!=、<、>、in、like、not之類的)的方法. criteria.andIdEqualTo(paramId).andAgeIn(Arrays.asList({10,20,30})); xxxMapper.updateByExampleSelective(xx,example);
相關文章
相關標籤/搜索