/** * @param cb Condition-bean. (NotNull) * @param entity Entity. (NotNull) * @return The two-way SQL of query update. (NullAllowed: If the set of modified properties is empty, return null.) */ protected String buildQueryUpdateTwoWaySql(ConditionBean cb, Entity entity) { Map <String, String> columnParameterMap = new LinkedHashMap <String, String>(); DBMeta dbmeta = DBMetaInstanceHandler.FindDBMeta(entity.TableDbName); System.Collections.Generic.IDictionary <String, Object> modifiedPropertyNames = entity.ModifiedPropertyNames; if (modifiedPropertyNames.Count == 0) { return(null); } String currentPropertyName = null; foreach (String propertyName in modifiedPropertyNames.Keys) { currentPropertyName = propertyName; ColumnInfo columnInfo = dbmeta.FindColumnInfo(propertyName); String columnName = columnInfo.ColumnDbName; PropertyInfo getter = columnInfo.FindProperty(); Object value = getter.GetValue(entity, null); if (value != null) { columnParameterMap.put(columnName, "/*entity." + propertyName + "*/null"); } else { columnParameterMap.put(columnName, "null"); } } if (dbmeta.HasVersionNo) { ColumnInfo columnInfo = dbmeta.VersionNoColumnInfo; String columnName = columnInfo.ColumnDbName; columnParameterMap.put(columnName, columnName + " + 1"); } if (dbmeta.HasUpdateDate) { ColumnInfo columnInfo = dbmeta.UpdateDateColumnInfo; PropertyInfo setter = columnInfo.FindProperty(); setter.SetValue(entity, DateTime.Now, null); String columnName = columnInfo.ColumnDbName; columnParameterMap.put(columnName, "/*entity." + columnInfo.PropertyName + "*/null"); } return(cb.SqlClause.getClauseQueryUpdate(columnParameterMap)); }