Package org.nutz.dao.impl.sql.pojo

Source Code of org.nutz.dao.impl.sql.pojo.QueryEntityFieldsPItem

package org.nutz.dao.impl.sql.pojo;

import java.util.List;

import org.nutz.dao.FieldMatcher;
import org.nutz.dao.entity.Entity;
import org.nutz.dao.entity.MappingField;
import org.nutz.lang.Lang;

public class QueryEntityFieldsPItem extends NoParamsPItem {

    public void joinSql(Entity<?> en, StringBuilder sb) {
        FieldMatcher fm = getFieldMatcher();
        if (null == fm) {
            sb.append("* ");
        } else {
            List<MappingField> efs = _en(en).getMappingFields();

            int old = sb.length();

            for (MappingField ef : efs) {
                if (fm.match(ef.getName()))
                    sb.append(ef.getColumnName()).append(',');
            }

            if (sb.length() == old)
                throw Lang.makeThrow("No columns be queryed: '%s'", _en(en));

            sb.setCharAt(sb.length() - 1, ' ');
        }
    }

}
TOP

Related Classes of org.nutz.dao.impl.sql.pojo.QueryEntityFieldsPItem

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.