@Test public void testInsertParametrized() { a(dialect.insertParametrized( Person.getMetaModel(), Arrays.asList("testField1", "testField2"), false)) .shouldBeEqual("INSERT INTO people (testField1, testField2) VALUES (?, ?)"); }
@Override public String insertParametrized(MetaModel metaModel, List<String> columns, boolean containsId) { StringBuilder query = new StringBuilder().append("INSERT INTO ").append(metaModel.getTableName()).append(' '); if (columns.isEmpty()) { appendEmptyRow(metaModel, query); } else { boolean addIdGeneratorCode = (!containsId && metaModel.getIdGeneratorCode() != null); query.append('('); if (addIdGeneratorCode) { query.append(metaModel.getIdName()).append(", "); } join(query, columns, ", "); query.append(") VALUES ("); if (addIdGeneratorCode) { query.append(metaModel.getIdGeneratorCode()).append(", "); } appendQuestions(query, columns.size()); query.append(')'); } return query.toString(); }
DefaultDialect implements Dialect { @Override public String insertParametrized(MetaModel metaModel, List<String> columns, boolean containsId) { StringBuilder query = new StringBuilder().append("INSERT INTO ").append(metaModel.getTableName()).append(' '); if (columns.isEmpty()) { appendEmptyRow(metaModel, query); } else { boolean addIdGeneratorCode = (!containsId && metaModel.getIdGeneratorCode() != null); query.append('('); if (addIdGeneratorCode) { query.append(metaModel.getIdName()).append(", "); } join(query, columns, ", "); query.append(") VALUES ("); if (addIdGeneratorCode) { query.append(metaModel.getIdGeneratorCode()).append(", "); } appendQuestions(query, columns.size()); query.append(')'); } return query.toString(); } }
DefaultDialect implements Dialect { @Override public String insertParametrized(MetaModel metaModel, List<String> columns, boolean containsId) { StringBuilder query = new StringBuilder().append("INSERT INTO ").append(metaModel.getTableName()).append(' '); if (columns.isEmpty()) { appendEmptyRow(metaModel, query); } else { boolean addIdGeneratorCode = (!containsId && metaModel.getIdGeneratorCode() != null); query.append('('); if (addIdGeneratorCode) { query.append(metaModel.getIdName()).append(", "); } join(query, columns, ", "); query.append(") VALUES ("); if (addIdGeneratorCode) { query.append(metaModel.getIdGeneratorCode()).append(", "); } appendQuestions(query, columns.size()); query.append(')'); } return query.toString(); }  }
DefaultDialect implements Dialect { @Override public String insertParametrized(MetaModel metaModel, List<String> columns, boolean containsId) { StringBuilder query = new StringBuilder().append("INSERT INTO ").append(metaModel.getTableName()).append(' '); if (columns.isEmpty()) { appendEmptyRow(metaModel, query); } else { boolean addIdGeneratorCode = (!containsId && metaModel.getIdGeneratorCode() != null); query.append('('); if (addIdGeneratorCode) { query.append(metaModel.getIdName()).append(", "); } join(query, columns, ", "); query.append(") VALUES ("); if (addIdGeneratorCode) { query.append(metaModel.getIdGeneratorCode()).append(", "); } appendQuestions(query, columns.size()); query.append(')'); } return query.toString(); }  @Override String selectStar(String table); @Override String selectStar(String table, String where); @Override String selectStarParametrized(String table, String ... parameters); @Override String formSelect(String tableName, String[] columns, String subQuery, List<String> orderBys, long limit, long offset); @Override Object overrideDriverTypeConversion(MetaModel mm, String attributeName, Object value); @Override String selectCount(String from); @Override String selectCount(String table, String where); @Override String selectExists(MetaModel metaModel); @Override String selectManyToManyAssociation(Many2ManyAssociation association, String sourceFkColumnName, int questionsCount); @Override String insertManyToManyAssociation(Many2ManyAssociation association); @Override String insertParametrized(MetaModel metaModel, List<String> columns, boolean containsId); @Override String deleteManyToManyAssociation(Many2ManyAssociation association); @Override String insert(MetaModel metaModel, Map<String, Object> attributes, String ... replacements); @Override String update(MetaModel metaModel, Map<String, Object> attributes, String ... replacements); }
DefaultDialect implements Dialect { @Override public String insertParametrized(MetaModel metaModel, List<String> columns, boolean containsId) { StringBuilder query = new StringBuilder().append("INSERT INTO ").append(metaModel.getTableName()).append(' '); if (columns.isEmpty()) { appendEmptyRow(metaModel, query); } else { boolean addIdGeneratorCode = (!containsId && metaModel.getIdGeneratorCode() != null); query.append('('); if (addIdGeneratorCode) { query.append(metaModel.getIdName()).append(", "); } join(query, columns, ", "); query.append(") VALUES ("); if (addIdGeneratorCode) { query.append(metaModel.getIdGeneratorCode()).append(", "); } appendQuestions(query, columns.size()); query.append(')'); } return query.toString(); }  @Override String selectStar(String table); @Override String selectStar(String table, String where); @Override String selectStarParametrized(String table, String ... parameters); @Override String formSelect(String tableName, String[] columns, String subQuery, List<String> orderBys, long limit, long offset); @Override Object overrideDriverTypeConversion(MetaModel mm, String attributeName, Object value); @Override String selectCount(String from); @Override String selectCount(String table, String where); @Override String selectExists(MetaModel metaModel); @Override String selectManyToManyAssociation(Many2ManyAssociation association, String sourceFkColumnName, int questionsCount); @Override String insertManyToManyAssociation(Many2ManyAssociation association); @Override String insertParametrized(MetaModel metaModel, List<String> columns, boolean containsId); @Override String deleteManyToManyAssociation(Many2ManyAssociation association); @Override String insert(MetaModel metaModel, Map<String, Object> attributes, String ... replacements); @Override String update(MetaModel metaModel, Map<String, Object> attributes, String ... replacements);  }