public M _setAttrs(Map<String, Object> attrs) {
		for (Entry<String, Object> e : attrs.entrySet())
			set(e.getKey(), e.getValue());
		return (M)this;
	}
	
	/*
	private Set<String> getModifyFlag() {
		if (modifyFlag == null)
			modifyFlag = getConfig().containerFactory.getModifyFlagSet();	// new HashSet<String>();
		return modifyFlag;
	}*/
	
	protected Set<String> _getModifyFlag() {
		if (modifyFlag == null) {
			Config config = _getConfig();
			if (config == null)
				modifyFlag = DbKit.brokenConfig.containerFactory.getModifyFlagSet();
			else
				modifyFlag = config.containerFactory.getModifyFlagSet();
		}
		return modifyFlag;
	}
	
	protected Config _getConfig() {
		if (configName != null)
			return DbKit.getConfig(configName);
		return DbKit.getConfig(_getUsefulClass());
	}
	
	/*
	private Config getConfig() {
		return DbKit.getConfig(getUsefulClass());
	}*/
	
	protected Table _getTable() {
		return TableMapping.me().getTable(_getUsefulClass());
	}
	
	protected Class<? extends Model> _getUsefulClass() {
		Class c = getClass();
		// guice : Model$$EnhancerByGuice$$40471411
		// cglib : com.demo.blog.Blog$$EnhancerByCGLIB$$69a17158
		// return c.getName().indexOf("EnhancerByCGLIB") == -1 ? c : c.getSuperclass();
		return c.getName().indexOf("$$EnhancerBy") == -1 ? c : c.getSuperclass();
	}
	
	/**
	 * Switching data source, dialect and all config by configName
	 */
	public M use(String configName) {
		if (attrs == DaoContainerFactory.daoMap) {
			throw new RuntimeException("dao 只允许调用查询方法");
		}
		
		this.configName = configName;
		return (M)this;
	}
	
	/**
	 * Set attribute to model.
	 * @param attr the attribute name of the model
	 * @param value the value of the attribute
	 * @return this model
	 * @throws ActiveRecordException if the attribute is not exists of the model
	 */
	public M set(String attr, Object value) {
		Table table = _getTable();	// table 为 null 时用于未启动 ActiveRecordPlugin 的场景
		if (table != null && !table.hasColumnLabel(attr)) {
			throw new ActiveRecordException("The attribute name does not exist: \"" + attr + "\"");
		}
		
		attrs.put(attr, value);
		_getModifyFlag().add(attr);	// Add modify flag, update() need this flag.
		return (M)this;
	}
	
	// public static transient boolean checkPutKey = true;
	/**
	 * Put key value pair to the model without check attribute name.
	 */
	public M put(String key, Object value) {
		/*
		if (checkPutKey) {
			Table table = getTable();	// table 为 null 时用于未启动 ActiveRecordPlugin 的场景
			if (table != null && table.hasColumnLabel(key)) {
				throw new ActiveRecordException("The key can not be attribute name: \"" + key + "\", using set(String, Object) for attribute value");
			}
		}*/
		attrs.put(key, value);
		return (M)this;
	}
public M _setAttrs ( Map < String , Object > attrs ) { for ( Entry < String , Object > e : attrs . entrySet ( ) ) set ( e . getKey ( ) , e . getValue ( ) ) ; return ( M ) this ; } protected Set < String > _getModifyFlag ( ) { if ( modifyFlag == null ) { Config config = _getConfig ( ) ; if ( config == null ) modifyFlag = DbKit . brokenConfig . containerFactory . getModifyFlagSet ( ) ; else modifyFlag = config . containerFactory . getModifyFlagSet ( ) ; } return modifyFlag ; } protected Config _getConfig ( ) { if ( configName != null ) return DbKit . getConfig ( configName ) ; return DbKit . getConfig ( _getUsefulClass ( ) ) ; } protected Table _getTable ( ) { return TableMapping . me ( ) . getTable ( _getUsefulClass ( ) ) ; } protected Class < ? extends Model > _getUsefulClass ( ) { Class c = getClass ( ) ; return c . getName ( ) . indexOf ( "$$EnhancerBy" ) == - 1 ? c : c . getSuperclass ( ) ; } public M use ( String configName ) { if ( attrs == DaoContainerFactory . daoMap ) { throw new RuntimeException ( "dao 只允许调用查询方法" ) ; } this . configName = configName ; return ( M ) this ; } public M set ( String attr , Object value ) { Table table = _getTable ( ) ; if ( table != null && ! table . hasColumnLabel ( attr ) ) { throw new ActiveRecordException ( "The attribute name does not exist: \"" + attr + "\"" ) ; } attrs . put ( attr , value ) ; _getModifyFlag ( ) . add ( attr ) ; return ( M ) this ; } public M put ( String key , Object value ) { attrs . put ( key , value ) ; return ( M ) this ; }
Set attributes with Map.
@param attrs attributes of this model
@return this Model