The or method in the Example generated by mybatis reverse engineering

  1. Test the Or method of Example —– Create a condition into the condition [set] and return the condition.

public void or(Criteria criteria) {
    oredCriteria.add(criteria);
}

public Criteria or() {
    Criteria criteria = createCriteriaInternal();
    oredCriteria.add(criteria);
    return criteria;
}

<foreach collection="oredCriteria" item="criteria" separator="or" >
  <if test="criteria.valid" >
    <trim prefix="(" suffix=")" prefixOverrides="and" >
      <foreach collection="criteria.criteria" item="criterion" >
        <choose >
          <when test="criterion.noValue" >
            and ${criterion.condition}
          </when>
          <when test="criterion.singleValue" >
            and ${criterion.condition} #{criterion.value}
          </when>
          <when test="criterion.betweenValue" >
            and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
          </when>
          <when test="criterion.listValue" >
            and ${criterion.condition}
            <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
              #{listItem}
            </foreach>
          </when>
        </choose>
      </foreach>
    </trim>
  </if>
</foreach>

Leave a Comment

Your email address will not be published. Required fields are marked *