mybatis

作者: 张三的张 | 来源:发表于2017-06-12 01:39 被阅读0次

mybatis 高级映射

  • 一对一
<association property="adposition" column="ad_position_id" select="com.huixin.dao.AdpositionMapper.selectByPrimaryKey"/>
  • 一对多
<collection property="skuList" column="material_id" select="com.huixin.dao.MaterialSkuMapper.getMaterialSkuByMaterialId" />

mybatis generator 的使用

  • 多个条件 or 连接查询
//例如: name like '%张三%' or nike_name like zhangsan and status=0 这种查询
ShopExample example = new ShopExample();
Criteria where = example.createCriteria();
where.addCriterion( " ( company_type=" + companyType + " or company_type=" + companyType1 +")" );
where.andStatusEqualTo( status );

但是需要将 xxxExample 类的对应方法的访问修饰符改为public

相关文章

网友评论

      本文标题:mybatis

      本文链接:https://www.haomeiwen.com/subject/xsikqxtx.html