Source:
<code>protected MappedEntity createPreparedStatementForInserts(final DbEntity entity) throws DatabaseEngineException { final List<String> insertInto = new ArrayList<>(); insertInto.add("INSERT INTO"); insertInto.add(quotize(entity.getName())); final List<String> insertIntoWithAutoInc = new ArrayList<>(); insertIntoWithAutoInc.add("INSERT INTO"); insertIntoWithAutoInc.add(quotize(entity.getName())); final List<String> columns = new ArrayList<>(); final List<String> values = new ArrayList<>(); final List<String> columnsWithAutoInc = new ArrayList<>(); final List<String> valuesWithAutoInc = new ArrayList<>(); String columnWithAutoIncName = null; for (final DbColumn column : entity.getColumns()) { columnsWithAutoInc.add(quotize(column.getName())); valuesWithAutoInc.add("?"); <START> if (column.isAutoInc()) { <END> columnWithAutoIncName = column.getName(); } else { columns.add(quotize(column.getName())); values.add("?"); } } insertInto.add("(" + join(columns, ", ") + ")"); insertInto.add("VALUES (" + join(values, ", ") + ")"); insertIntoWithAutoInc.add("(" + join(columnsWithAutoInc, ", ") + ")"); insertIntoWithAutoInc.add("VALUES (" + join(valuesWithAutoInc, ", ") + ")"); final String statement = join(insertInto, " "); final String insertReturnStatement = ""; final String statementWithAutoInt = join(insertIntoWithAutoInc, " "); logger.trace(statement); final PreparedStatement ps, psReturn, psWithAutoInc; try { ps = conn.prepareStatement(statement, Statement.RETURN_GENERATED_KEYS); psReturn = conn.prepareStatement(insertReturnStatement); psWithAutoInc = conn.prepareStatement(statementWithAutoInt); return new MappedEntity().setInsert(ps) .setInsertReturning(psReturn) .setInsertWithAutoInc(psWithAutoInc) .setAutoIncColumn(columnWithAutoIncName); } catch (final SQLException ex) { throw new DatabaseEngineException("Something went wrong handling statement", ex); } }</code><technical_language>If more column auto_increment end assuming provides entity id is one. continue a string instead of a list set this string more once</technical_language>

Target:
protected MappedEntity createPreparedStatementForInserts(final DbEntity entity) throws DatabaseEngineException { final List<String> insertInto = new ArrayList<>(); insertInto.add("INSERT INTO"); insertInto.add(quotize(entity.getName())); final List<String> insertIntoWithAutoInc = new ArrayList<>(); insertIntoWithAutoInc.add("INSERT INTO"); insertIntoWithAutoInc.add(quotize(entity.getName())); final List<String> columns = new ArrayList<>(); final List<String> values = new ArrayList<>(); final List<String> columnsWithAutoInc = new ArrayList<>(); final List<String> valuesWithAutoInc = new ArrayList<>(); String columnWithAutoIncName = null; for (final DbColumn column : entity.getColumns()) { columnsWithAutoInc.add(quotize(column.getName())); valuesWithAutoInc.add("?"); if (column.isAutoInc()) { columnWithAutoIncName = column.getName(); } else { columns.add(quotize(column.getName())); values.add("?"); } } insertInto.add("(" + join(columns, ", ") + ")"); insertInto.add("VALUES (" + join(values, ", ") + ")"); insertIntoWithAutoInc.add("(" + join(columnsWithAutoInc, ", ") + ")"); insertIntoWithAutoInc.add("VALUES (" + join(valuesWithAutoInc, ", ") + ")"); final String statement = join(insertInto, " "); final String insertReturnStatement = ""; final String statementWithAutoInt = join(insertIntoWithAutoInc, " "); logger.trace(statement); final PreparedStatement ps, psReturn, psWithAutoInc; try { final int generateKeys = columnWithAutoIncName != null? Statement.RETURN_GENERATED_KEYS : Statement.NO_GENERATED_KEYS; ps = this.conn.prepareStatement(statement, generateKeys); psReturn = this.conn.prepareStatement(insertReturnStatement, generateKeys); psWithAutoInc = this.conn.prepareStatement(statementWithAutoInt, generateKeys); return new MappedEntity() .setInsert(ps) .setInsertReturning(psReturn) .setInsertWithAutoInc(psWithAutoInc) .setAutoIncColumn(columnWithAutoIncName); } catch (final SQLException ex) { throw new DatabaseEngineException("Something went wrong handling statement", ex); } }