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 類的對應(yīng)方法的訪問修飾符改為public