public String generateUpdateSql ( String namespace , int id ) { // Collect field names for string joining from JsonObject. String joinedFieldNames = editorFields ( ) . stream ( ) // If updating, add suffix for use in set clause . map ( field -> field . name + " = ?" ) . collect ( Collectors . joining ( ", " ) ) ; String tableName = namespace == null ? name : String . join ( "." , namespace , name ) ; return String . format ( "update %s set %s where id = %d" , tableName , joinedFieldNames , id ) ; }
Create SQL string for use in update statement . Note this filters table s fields to only those used in editor .