public String generateInsertSql ( String namespace , boolean setDefaultId ) { String tableName = namespace == null ? name : String . join ( "." , namespace , name ) ; String joinedFieldNames = commaSeparatedNames ( editorFields ( ) ) ; String idValue = setDefaultId ? "DEFAULT" : "?" ; return String . format ( "insert into %s (id, %s) values (%s, %s)" , tableName , joinedFieldNames , idValue , String . join ( ", " , Collections . nCopies ( editorFields ( ) . size ( ) , "?" ) ) ) ; }
Create SQL string for use in insert statement . Note this filters table s fields to only those used in editor .