@Override public void process(StringBuilder out) { if (isPreviousChunkOfType(CHUNK_TABLE)) { appendMissingSpace(out); } DbEntityDescriptor ded = tableRef != null ? lookupTableRef(tableRef) : lookupType(resolveClass(data)); out.append(SET); DbEntityColumnDescriptor[] decList = ded.getColumnDescriptors(); String typeName = StringUtil.uncapitalize(ded.getEntityName()); // String table = resolveTable(tableRef, ded); int size = 0; for (DbEntityColumnDescriptor dec : decList) { String property = dec.getPropertyName(); Object value = BeanUtil.getDeclaredProperty(data, property); if (includeColumns == COLS_ONLY_EXISTING) { if (DbOomUtil.isEmptyColumnValue(dec, value)) { continue; } } if (size > 0) { out.append(',').append(' '); } size++; // do not add table reference in set // as only one table can be updated // also, Postgress database does not allow it (see #JODD-21) // out.append(table).append('.'); out.append(dec.getColumnName()).append('='); String propertyName = typeName + '.' + property; defineParameter(out, propertyName, value, dec); } if (size > 0) { out.append(' '); } }
@Override public void process(StringBuilder out) { // hints if (templateData.hasHints()) { templateData.registerHint(hint == null ? tableRef : hint); } // columns separateByCommaOrSpace(out); // special case, only column name, no table ref/name if (tableRef.length() == 0) { out.append(columnRef); return; } boolean useTableReference = true; DbEntityDescriptor ded = lookupTableRef(tableRef, false); if (ded == null) { useTableReference = false; ded = lookupName(tableRef); } if (columnRef == null) { DbEntityColumnDescriptor[] decList = ded.getColumnDescriptors(); int count = 0; boolean withIds = (columnRefArr != null) && ArraysUtil.contains(columnRefArr, StringPool.PLUS); for (DbEntityColumnDescriptor dec : decList) { if ((includeColumns == COLS_ONLY_IDS) && (dec.isId() == false)) { continue; } if ((includeColumns == COLS_ALL_BUT_ID) && (dec.isId() == true)) { continue; } if ((includeColumns == COLS_NA_MULTI) && (!withIds || (dec.isId() == false)) && (!ArraysUtil.contains(columnRefArr, dec.getPropertyName()))) { continue; } if (count > 0) { out.append(',').append(' '); } templateData.lastColumnDec = dec; if (useTableReference) { appendColumnName(out, ded, dec.getColumnName()); } else { appendAlias(out, ded, dec.getColumnName()); } count++; } } else { DbEntityColumnDescriptor dec = ded.findByPropertyName(columnRef); templateData.lastColumnDec = dec; String columnName = dec == null ? null : dec.getColumnName(); // String columnName = ded.getColumnName(columnRef); if (columnName == null) { throw new DbSqlBuilderException("Invalid column reference: " + tableRef + '.' + columnRef); } if (useTableReference) { appendColumnName(out, ded, columnName); } else { appendAlias(out, ded, columnName); } } }