package com.hfkj.dao;

import com.hfkj.entity.BsStoreSettleAcct;
import com.hfkj.entity.BsStoreSettleAcctExample.Criteria;
import com.hfkj.entity.BsStoreSettleAcctExample.Criterion;
import com.hfkj.entity.BsStoreSettleAcctExample;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.jdbc.SQL;

public class BsStoreSettleAcctSqlProvider {

    public String countByExample(BsStoreSettleAcctExample example) {
        SQL sql = new SQL();
        sql.SELECT("count(*)").FROM("bs_store_settle_acct");
        applyWhere(sql, example, false);
        return sql.toString();
    }

    public String deleteByExample(BsStoreSettleAcctExample example) {
        SQL sql = new SQL();
        sql.DELETE_FROM("bs_store_settle_acct");
        applyWhere(sql, example, false);
        return sql.toString();
    }

    public String insertSelective(BsStoreSettleAcct record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("bs_store_settle_acct");
        
        if (record.getMerId() != null) {
            sql.VALUES("mer_id", "#{merId,jdbcType=BIGINT}");
        }
        
        if (record.getStoreId() != null) {
            sql.VALUES("store_id", "#{storeId,jdbcType=BIGINT}");
        }
        
        if (record.getSettleType() != null) {
            sql.VALUES("settle_type", "#{settleType,jdbcType=INTEGER}");
        }
        
        if (record.getCommissionImg() != null) {
            sql.VALUES("commission_img", "#{commissionImg,jdbcType=VARCHAR}");
        }
        
        if (record.getBankCardImg() != null) {
            sql.VALUES("bank_card_img", "#{bankCardImg,jdbcType=VARCHAR}");
        }
        
        if (record.getBankName() != null) {
            sql.VALUES("bank_name", "#{bankName,jdbcType=VARCHAR}");
        }
        
        if (record.getBankCardNo() != null) {
            sql.VALUES("bank_card_no", "#{bankCardNo,jdbcType=VARCHAR}");
        }
        
        if (record.getBankCardHolder() != null) {
            sql.VALUES("bank_card_holder", "#{bankCardHolder,jdbcType=VARCHAR}");
        }
        
        if (record.getOpenningBankCityCode() != null) {
            sql.VALUES("openning_bank_city_code", "#{openningBankCityCode,jdbcType=BIGINT}");
        }
        
        if (record.getOpenningBankCityName() != null) {
            sql.VALUES("openning_bank_city_name", "#{openningBankCityName,jdbcType=VARCHAR}");
        }
        
        if (record.getOpenningBankAreaCode() != null) {
            sql.VALUES("openning_bank_area_code", "#{openningBankAreaCode,jdbcType=BIGINT}");
        }
        
        if (record.getOpenningBankAreaName() != null) {
            sql.VALUES("openning_bank_area_name", "#{openningBankAreaName,jdbcType=VARCHAR}");
        }
        
        if (record.getOpenningBankProvinceCode() != null) {
            sql.VALUES("openning_bank_province_code", "#{openningBankProvinceCode,jdbcType=BIGINT}");
        }
        
        if (record.getOpenningBankProvinceName() != null) {
            sql.VALUES("openning_bank_province_name", "#{openningBankProvinceName,jdbcType=VARCHAR}");
        }
        
        if (record.getOpenningBankCode() != null) {
            sql.VALUES("openning_bank_code", "#{openningBankCode,jdbcType=VARCHAR}");
        }
        
        if (record.getOpenningBankName() != null) {
            sql.VALUES("openning_bank_name", "#{openningBankName,jdbcType=VARCHAR}");
        }
        
        if (record.getOpenningBankLicenseUrl() != null) {
            sql.VALUES("openning_bank_license_url", "#{openningBankLicenseUrl,jdbcType=VARCHAR}");
        }
        
        if (record.getClearingBankCode() != null) {
            sql.VALUES("clearing_bank_code", "#{clearingBankCode,jdbcType=VARCHAR}");
        }
        
        if (record.getSettleIdCardName() != null) {
            sql.VALUES("settle_id_card_name", "#{settleIdCardName,jdbcType=VARCHAR}");
        }
        
        if (record.getSettleIdCardNo() != null) {
            sql.VALUES("settle_id_card_no", "#{settleIdCardNo,jdbcType=VARCHAR}");
        }
        
        if (record.getSettleIdCardPortraitImg() != null) {
            sql.VALUES("settle_id_card_portrait_img", "#{settleIdCardPortraitImg,jdbcType=VARCHAR}");
        }
        
        if (record.getSettleIdCardNationalEmblemImg() != null) {
            sql.VALUES("settle_id_card_national_emblem_img", "#{settleIdCardNationalEmblemImg,jdbcType=VARCHAR}");
        }
        
        if (record.getSettleIdPeriodType() != null) {
            sql.VALUES("settle_id_period_type", "#{settleIdPeriodType,jdbcType=INTEGER}");
        }
        
        if (record.getSettleIdCardPeriodStart() != null) {
            sql.VALUES("settle_id_card_period_start", "#{settleIdCardPeriodStart,jdbcType=VARCHAR}");
        }
        
        if (record.getSettleIdCardPeriodEnd() != null) {
            sql.VALUES("settle_id_card_period_end", "#{settleIdCardPeriodEnd,jdbcType=VARCHAR}");
        }
        
        if (record.getElectronicPact() != null) {
            sql.VALUES("electronic_pact", "#{electronicPact,jdbcType=VARCHAR}");
        }
        
        if (record.getStatus() != null) {
            sql.VALUES("`status`", "#{status,jdbcType=INTEGER}");
        }
        
        if (record.getCreateTime() != null) {
            sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getExt1() != null) {
            sql.VALUES("ext_1", "#{ext1,jdbcType=VARCHAR}");
        }
        
        if (record.getExt2() != null) {
            sql.VALUES("ext_2", "#{ext2,jdbcType=VARCHAR}");
        }
        
        if (record.getExt3() != null) {
            sql.VALUES("ext_3", "#{ext3,jdbcType=VARCHAR}");
        }
        
        return sql.toString();
    }

    public String selectByExample(BsStoreSettleAcctExample example) {
        SQL sql = new SQL();
        if (example != null && example.isDistinct()) {
            sql.SELECT_DISTINCT("id");
        } else {
            sql.SELECT("id");
        }
        sql.SELECT("mer_id");
        sql.SELECT("store_id");
        sql.SELECT("settle_type");
        sql.SELECT("commission_img");
        sql.SELECT("bank_card_img");
        sql.SELECT("bank_name");
        sql.SELECT("bank_card_no");
        sql.SELECT("bank_card_holder");
        sql.SELECT("openning_bank_city_code");
        sql.SELECT("openning_bank_city_name");
        sql.SELECT("openning_bank_area_code");
        sql.SELECT("openning_bank_area_name");
        sql.SELECT("openning_bank_province_code");
        sql.SELECT("openning_bank_province_name");
        sql.SELECT("openning_bank_code");
        sql.SELECT("openning_bank_name");
        sql.SELECT("openning_bank_license_url");
        sql.SELECT("clearing_bank_code");
        sql.SELECT("settle_id_card_name");
        sql.SELECT("settle_id_card_no");
        sql.SELECT("settle_id_card_portrait_img");
        sql.SELECT("settle_id_card_national_emblem_img");
        sql.SELECT("settle_id_period_type");
        sql.SELECT("settle_id_card_period_start");
        sql.SELECT("settle_id_card_period_end");
        sql.SELECT("electronic_pact");
        sql.SELECT("`status`");
        sql.SELECT("create_time");
        sql.SELECT("update_time");
        sql.SELECT("ext_1");
        sql.SELECT("ext_2");
        sql.SELECT("ext_3");
        sql.FROM("bs_store_settle_acct");
        applyWhere(sql, example, false);
        
        if (example != null && example.getOrderByClause() != null) {
            sql.ORDER_BY(example.getOrderByClause());
        }
        
        return sql.toString();
    }

    public String updateByExampleSelective(Map<String, Object> parameter) {
        BsStoreSettleAcct record = (BsStoreSettleAcct) parameter.get("record");
        BsStoreSettleAcctExample example = (BsStoreSettleAcctExample) parameter.get("example");
        
        SQL sql = new SQL();
        sql.UPDATE("bs_store_settle_acct");
        
        if (record.getId() != null) {
            sql.SET("id = #{record.id,jdbcType=BIGINT}");
        }
        
        if (record.getMerId() != null) {
            sql.SET("mer_id = #{record.merId,jdbcType=BIGINT}");
        }
        
        if (record.getStoreId() != null) {
            sql.SET("store_id = #{record.storeId,jdbcType=BIGINT}");
        }
        
        if (record.getSettleType() != null) {
            sql.SET("settle_type = #{record.settleType,jdbcType=INTEGER}");
        }
        
        if (record.getCommissionImg() != null) {
            sql.SET("commission_img = #{record.commissionImg,jdbcType=VARCHAR}");
        }
        
        if (record.getBankCardImg() != null) {
            sql.SET("bank_card_img = #{record.bankCardImg,jdbcType=VARCHAR}");
        }
        
        if (record.getBankName() != null) {
            sql.SET("bank_name = #{record.bankName,jdbcType=VARCHAR}");
        }
        
        if (record.getBankCardNo() != null) {
            sql.SET("bank_card_no = #{record.bankCardNo,jdbcType=VARCHAR}");
        }
        
        if (record.getBankCardHolder() != null) {
            sql.SET("bank_card_holder = #{record.bankCardHolder,jdbcType=VARCHAR}");
        }
        
        if (record.getOpenningBankCityCode() != null) {
            sql.SET("openning_bank_city_code = #{record.openningBankCityCode,jdbcType=BIGINT}");
        }
        
        if (record.getOpenningBankCityName() != null) {
            sql.SET("openning_bank_city_name = #{record.openningBankCityName,jdbcType=VARCHAR}");
        }
        
        if (record.getOpenningBankAreaCode() != null) {
            sql.SET("openning_bank_area_code = #{record.openningBankAreaCode,jdbcType=BIGINT}");
        }
        
        if (record.getOpenningBankAreaName() != null) {
            sql.SET("openning_bank_area_name = #{record.openningBankAreaName,jdbcType=VARCHAR}");
        }
        
        if (record.getOpenningBankProvinceCode() != null) {
            sql.SET("openning_bank_province_code = #{record.openningBankProvinceCode,jdbcType=BIGINT}");
        }
        
        if (record.getOpenningBankProvinceName() != null) {
            sql.SET("openning_bank_province_name = #{record.openningBankProvinceName,jdbcType=VARCHAR}");
        }
        
        if (record.getOpenningBankCode() != null) {
            sql.SET("openning_bank_code = #{record.openningBankCode,jdbcType=VARCHAR}");
        }
        
        if (record.getOpenningBankName() != null) {
            sql.SET("openning_bank_name = #{record.openningBankName,jdbcType=VARCHAR}");
        }
        
        if (record.getOpenningBankLicenseUrl() != null) {
            sql.SET("openning_bank_license_url = #{record.openningBankLicenseUrl,jdbcType=VARCHAR}");
        }
        
        if (record.getClearingBankCode() != null) {
            sql.SET("clearing_bank_code = #{record.clearingBankCode,jdbcType=VARCHAR}");
        }
        
        if (record.getSettleIdCardName() != null) {
            sql.SET("settle_id_card_name = #{record.settleIdCardName,jdbcType=VARCHAR}");
        }
        
        if (record.getSettleIdCardNo() != null) {
            sql.SET("settle_id_card_no = #{record.settleIdCardNo,jdbcType=VARCHAR}");
        }
        
        if (record.getSettleIdCardPortraitImg() != null) {
            sql.SET("settle_id_card_portrait_img = #{record.settleIdCardPortraitImg,jdbcType=VARCHAR}");
        }
        
        if (record.getSettleIdCardNationalEmblemImg() != null) {
            sql.SET("settle_id_card_national_emblem_img = #{record.settleIdCardNationalEmblemImg,jdbcType=VARCHAR}");
        }
        
        if (record.getSettleIdPeriodType() != null) {
            sql.SET("settle_id_period_type = #{record.settleIdPeriodType,jdbcType=INTEGER}");
        }
        
        if (record.getSettleIdCardPeriodStart() != null) {
            sql.SET("settle_id_card_period_start = #{record.settleIdCardPeriodStart,jdbcType=VARCHAR}");
        }
        
        if (record.getSettleIdCardPeriodEnd() != null) {
            sql.SET("settle_id_card_period_end = #{record.settleIdCardPeriodEnd,jdbcType=VARCHAR}");
        }
        
        if (record.getElectronicPact() != null) {
            sql.SET("electronic_pact = #{record.electronicPact,jdbcType=VARCHAR}");
        }
        
        if (record.getStatus() != null) {
            sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
        }
        
        if (record.getCreateTime() != null) {
            sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getExt1() != null) {
            sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}");
        }
        
        if (record.getExt2() != null) {
            sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}");
        }
        
        if (record.getExt3() != null) {
            sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}");
        }
        
        applyWhere(sql, example, true);
        return sql.toString();
    }

    public String updateByExample(Map<String, Object> parameter) {
        SQL sql = new SQL();
        sql.UPDATE("bs_store_settle_acct");
        
        sql.SET("id = #{record.id,jdbcType=BIGINT}");
        sql.SET("mer_id = #{record.merId,jdbcType=BIGINT}");
        sql.SET("store_id = #{record.storeId,jdbcType=BIGINT}");
        sql.SET("settle_type = #{record.settleType,jdbcType=INTEGER}");
        sql.SET("commission_img = #{record.commissionImg,jdbcType=VARCHAR}");
        sql.SET("bank_card_img = #{record.bankCardImg,jdbcType=VARCHAR}");
        sql.SET("bank_name = #{record.bankName,jdbcType=VARCHAR}");
        sql.SET("bank_card_no = #{record.bankCardNo,jdbcType=VARCHAR}");
        sql.SET("bank_card_holder = #{record.bankCardHolder,jdbcType=VARCHAR}");
        sql.SET("openning_bank_city_code = #{record.openningBankCityCode,jdbcType=BIGINT}");
        sql.SET("openning_bank_city_name = #{record.openningBankCityName,jdbcType=VARCHAR}");
        sql.SET("openning_bank_area_code = #{record.openningBankAreaCode,jdbcType=BIGINT}");
        sql.SET("openning_bank_area_name = #{record.openningBankAreaName,jdbcType=VARCHAR}");
        sql.SET("openning_bank_province_code = #{record.openningBankProvinceCode,jdbcType=BIGINT}");
        sql.SET("openning_bank_province_name = #{record.openningBankProvinceName,jdbcType=VARCHAR}");
        sql.SET("openning_bank_code = #{record.openningBankCode,jdbcType=VARCHAR}");
        sql.SET("openning_bank_name = #{record.openningBankName,jdbcType=VARCHAR}");
        sql.SET("openning_bank_license_url = #{record.openningBankLicenseUrl,jdbcType=VARCHAR}");
        sql.SET("clearing_bank_code = #{record.clearingBankCode,jdbcType=VARCHAR}");
        sql.SET("settle_id_card_name = #{record.settleIdCardName,jdbcType=VARCHAR}");
        sql.SET("settle_id_card_no = #{record.settleIdCardNo,jdbcType=VARCHAR}");
        sql.SET("settle_id_card_portrait_img = #{record.settleIdCardPortraitImg,jdbcType=VARCHAR}");
        sql.SET("settle_id_card_national_emblem_img = #{record.settleIdCardNationalEmblemImg,jdbcType=VARCHAR}");
        sql.SET("settle_id_period_type = #{record.settleIdPeriodType,jdbcType=INTEGER}");
        sql.SET("settle_id_card_period_start = #{record.settleIdCardPeriodStart,jdbcType=VARCHAR}");
        sql.SET("settle_id_card_period_end = #{record.settleIdCardPeriodEnd,jdbcType=VARCHAR}");
        sql.SET("electronic_pact = #{record.electronicPact,jdbcType=VARCHAR}");
        sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
        sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
        sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}");
        sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}");
        sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}");
        sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}");
        
        BsStoreSettleAcctExample example = (BsStoreSettleAcctExample) parameter.get("example");
        applyWhere(sql, example, true);
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(BsStoreSettleAcct record) {
        SQL sql = new SQL();
        sql.UPDATE("bs_store_settle_acct");
        
        if (record.getMerId() != null) {
            sql.SET("mer_id = #{merId,jdbcType=BIGINT}");
        }
        
        if (record.getStoreId() != null) {
            sql.SET("store_id = #{storeId,jdbcType=BIGINT}");
        }
        
        if (record.getSettleType() != null) {
            sql.SET("settle_type = #{settleType,jdbcType=INTEGER}");
        }
        
        if (record.getCommissionImg() != null) {
            sql.SET("commission_img = #{commissionImg,jdbcType=VARCHAR}");
        }
        
        if (record.getBankCardImg() != null) {
            sql.SET("bank_card_img = #{bankCardImg,jdbcType=VARCHAR}");
        }
        
        if (record.getBankName() != null) {
            sql.SET("bank_name = #{bankName,jdbcType=VARCHAR}");
        }
        
        if (record.getBankCardNo() != null) {
            sql.SET("bank_card_no = #{bankCardNo,jdbcType=VARCHAR}");
        }
        
        if (record.getBankCardHolder() != null) {
            sql.SET("bank_card_holder = #{bankCardHolder,jdbcType=VARCHAR}");
        }
        
        if (record.getOpenningBankCityCode() != null) {
            sql.SET("openning_bank_city_code = #{openningBankCityCode,jdbcType=BIGINT}");
        }
        
        if (record.getOpenningBankCityName() != null) {
            sql.SET("openning_bank_city_name = #{openningBankCityName,jdbcType=VARCHAR}");
        }
        
        if (record.getOpenningBankAreaCode() != null) {
            sql.SET("openning_bank_area_code = #{openningBankAreaCode,jdbcType=BIGINT}");
        }
        
        if (record.getOpenningBankAreaName() != null) {
            sql.SET("openning_bank_area_name = #{openningBankAreaName,jdbcType=VARCHAR}");
        }
        
        if (record.getOpenningBankProvinceCode() != null) {
            sql.SET("openning_bank_province_code = #{openningBankProvinceCode,jdbcType=BIGINT}");
        }
        
        if (record.getOpenningBankProvinceName() != null) {
            sql.SET("openning_bank_province_name = #{openningBankProvinceName,jdbcType=VARCHAR}");
        }
        
        if (record.getOpenningBankCode() != null) {
            sql.SET("openning_bank_code = #{openningBankCode,jdbcType=VARCHAR}");
        }
        
        if (record.getOpenningBankName() != null) {
            sql.SET("openning_bank_name = #{openningBankName,jdbcType=VARCHAR}");
        }
        
        if (record.getOpenningBankLicenseUrl() != null) {
            sql.SET("openning_bank_license_url = #{openningBankLicenseUrl,jdbcType=VARCHAR}");
        }
        
        if (record.getClearingBankCode() != null) {
            sql.SET("clearing_bank_code = #{clearingBankCode,jdbcType=VARCHAR}");
        }
        
        if (record.getSettleIdCardName() != null) {
            sql.SET("settle_id_card_name = #{settleIdCardName,jdbcType=VARCHAR}");
        }
        
        if (record.getSettleIdCardNo() != null) {
            sql.SET("settle_id_card_no = #{settleIdCardNo,jdbcType=VARCHAR}");
        }
        
        if (record.getSettleIdCardPortraitImg() != null) {
            sql.SET("settle_id_card_portrait_img = #{settleIdCardPortraitImg,jdbcType=VARCHAR}");
        }
        
        if (record.getSettleIdCardNationalEmblemImg() != null) {
            sql.SET("settle_id_card_national_emblem_img = #{settleIdCardNationalEmblemImg,jdbcType=VARCHAR}");
        }
        
        if (record.getSettleIdPeriodType() != null) {
            sql.SET("settle_id_period_type = #{settleIdPeriodType,jdbcType=INTEGER}");
        }
        
        if (record.getSettleIdCardPeriodStart() != null) {
            sql.SET("settle_id_card_period_start = #{settleIdCardPeriodStart,jdbcType=VARCHAR}");
        }
        
        if (record.getSettleIdCardPeriodEnd() != null) {
            sql.SET("settle_id_card_period_end = #{settleIdCardPeriodEnd,jdbcType=VARCHAR}");
        }
        
        if (record.getElectronicPact() != null) {
            sql.SET("electronic_pact = #{electronicPact,jdbcType=VARCHAR}");
        }
        
        if (record.getStatus() != null) {
            sql.SET("`status` = #{status,jdbcType=INTEGER}");
        }
        
        if (record.getCreateTime() != null) {
            sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getExt1() != null) {
            sql.SET("ext_1 = #{ext1,jdbcType=VARCHAR}");
        }
        
        if (record.getExt2() != null) {
            sql.SET("ext_2 = #{ext2,jdbcType=VARCHAR}");
        }
        
        if (record.getExt3() != null) {
            sql.SET("ext_3 = #{ext3,jdbcType=VARCHAR}");
        }
        
        sql.WHERE("id = #{id,jdbcType=BIGINT}");
        
        return sql.toString();
    }

    protected void applyWhere(SQL sql, BsStoreSettleAcctExample example, boolean includeExamplePhrase) {
        if (example == null) {
            return;
        }
        
        String parmPhrase1;
        String parmPhrase1_th;
        String parmPhrase2;
        String parmPhrase2_th;
        String parmPhrase3;
        String parmPhrase3_th;
        if (includeExamplePhrase) {
            parmPhrase1 = "%s #{example.oredCriteria[%d].allCriteria[%d].value}";
            parmPhrase1_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}";
            parmPhrase2 = "%s #{example.oredCriteria[%d].allCriteria[%d].value} and #{example.oredCriteria[%d].criteria[%d].secondValue}";
            parmPhrase2_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{example.oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}";
            parmPhrase3 = "#{example.oredCriteria[%d].allCriteria[%d].value[%d]}";
            parmPhrase3_th = "#{example.oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}";
        } else {
            parmPhrase1 = "%s #{oredCriteria[%d].allCriteria[%d].value}";
            parmPhrase1_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}";
            parmPhrase2 = "%s #{oredCriteria[%d].allCriteria[%d].value} and #{oredCriteria[%d].criteria[%d].secondValue}";
            parmPhrase2_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}";
            parmPhrase3 = "#{oredCriteria[%d].allCriteria[%d].value[%d]}";
            parmPhrase3_th = "#{oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}";
        }
        
        StringBuilder sb = new StringBuilder();
        List<Criteria> oredCriteria = example.getOredCriteria();
        boolean firstCriteria = true;
        for (int i = 0; i < oredCriteria.size(); i++) {
            Criteria criteria = oredCriteria.get(i);
            if (criteria.isValid()) {
                if (firstCriteria) {
                    firstCriteria = false;
                } else {
                    sb.append(" or ");
                }
                
                sb.append('(');
                List<Criterion> criterions = criteria.getAllCriteria();
                boolean firstCriterion = true;
                for (int j = 0; j < criterions.size(); j++) {
                    Criterion criterion = criterions.get(j);
                    if (firstCriterion) {
                        firstCriterion = false;
                    } else {
                        sb.append(" and ");
                    }
                    
                    if (criterion.isNoValue()) {
                        sb.append(criterion.getCondition());
                    } else if (criterion.isSingleValue()) {
                        if (criterion.getTypeHandler() == null) {
                            sb.append(String.format(parmPhrase1, criterion.getCondition(), i, j));
                        } else {
                            sb.append(String.format(parmPhrase1_th, criterion.getCondition(), i, j,criterion.getTypeHandler()));
                        }
                    } else if (criterion.isBetweenValue()) {
                        if (criterion.getTypeHandler() == null) {
                            sb.append(String.format(parmPhrase2, criterion.getCondition(), i, j, i, j));
                        } else {
                            sb.append(String.format(parmPhrase2_th, criterion.getCondition(), i, j, criterion.getTypeHandler(), i, j, criterion.getTypeHandler()));
                        }
                    } else if (criterion.isListValue()) {
                        sb.append(criterion.getCondition());
                        sb.append(" (");
                        List<?> listItems = (List<?>) criterion.getValue();
                        boolean comma = false;
                        for (int k = 0; k < listItems.size(); k++) {
                            if (comma) {
                                sb.append(", ");
                            } else {
                                comma = true;
                            }
                            if (criterion.getTypeHandler() == null) {
                                sb.append(String.format(parmPhrase3, i, j, k));
                            } else {
                                sb.append(String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler()));
                            }
                        }
                        sb.append(')');
                    }
                }
                sb.append(')');
            }
        }
        
        if (sb.length() > 0) {
            sql.WHERE(sb.toString());
        }
    }
}