m.id, m.name as kee, m.description, m.direction, m.domain, m.short_name as shortName, m.qualitative, m.val_type as valueType, m.user_managed as userManaged, m.enabled, m.worst_value as worstValue, m.best_value as bestValue, m.optimized_best_value as optimizedBestValue, m.hidden, m.delete_historical_data as deleteHistoricalData, m.decimal_scale as decimalScale INSERT INTO metrics ( name, description, direction, domain, short_name, qualitative, val_type, user_managed, enabled, worst_value, best_value, optimized_best_value, hidden, delete_historical_data, decimal_scale) VALUES ( #{kee, jdbcType=VARCHAR}, #{description, jdbcType=VARCHAR}, #{direction, jdbcType=INTEGER}, #{domain, jdbcType=VARCHAR}, #{shortName, jdbcType=VARCHAR}, #{qualitative, jdbcType=BOOLEAN}, #{valueType, jdbcType=VARCHAR}, #{userManaged, jdbcType=BOOLEAN}, #{enabled, jdbcType=BOOLEAN}, #{worstValue, jdbcType=DOUBLE}, #{bestValue, jdbcType=DOUBLE}, #{optimizedBestValue, jdbcType=BOOLEAN}, #{hidden, jdbcType=BOOLEAN}, #{deleteHistoricalData, jdbcType=BOOLEAN}, #{decimalScale, jdbcType=INTEGER} ) update metrics set name=#{key, jdbcType=VARCHAR}, short_name=#{shortName, jdbcType=VARCHAR}, val_type=#{valueType, jdbcType=VARCHAR}, enabled=#{enabled, jdbcType=BOOLEAN}, domain=#{domain, jdbcType=VARCHAR}, description=#{description, jdbcType=VARCHAR}, direction=#{direction, jdbcType=INTEGER}, hidden=#{hidden, jdbcType=BOOLEAN}, qualitative=#{qualitative, jdbcType=BOOLEAN}, decimal_scale=#{decimalScale, jdbcType=INTEGER} where id=#{id} update metrics set enabled=${_false} AND user_managed=${_true} AND id in #{id} update metrics set enabled=${_false} where name=#{key} and enabled=${_true}