@Test public void insertSql() { System.out.println(t.getInsertSql()); assertEquals("INSERT INTO user (user_id,user_name,pwd ) VALUES ( :userId,:userName,:pwd ) ", t.getInsertSql()); }
public String getInsertSql() { StringBuilder sb = new StringBuilder("INSERT INTO ").append(getTableName()).append(" ("); List<String> insertColumns = new ArrayList(getColumns().size()); List<String> insertPlaceholderColumns = new ArrayList(getColumns().size()); for(int i = 0; i < getColumns().size(); i++) { Column c = getColumns().get(i); if(c.isInsertable()) { insertColumns.add(c.getSqlName()); insertPlaceholderColumns.add(getColumnPlaceholder(c)); } } sb.append(StringUtils.join(insertColumns.iterator(), ",")); sb.append(" ) VALUES ( "); sb.append(StringUtils.join(insertPlaceholderColumns.iterator(), ",")); sb.append(" ) "); return sb.toString(); }
SpringNamedSqlGenerator implements SqlGenerator { public String getInsertSql() { StringBuilder sb = new StringBuilder("INSERT INTO ").append(getTableName()).append(" ("); List<String> insertColumns = new ArrayList(getColumns().size()); List<String> insertPlaceholderColumns = new ArrayList(getColumns().size()); for(int i = 0; i < getColumns().size(); i++) { Column c = getColumns().get(i); if(c.isInsertable()) { insertColumns.add(c.getSqlName()); insertPlaceholderColumns.add(getColumnPlaceholder(c)); } } sb.append(StringUtils.join(insertColumns.iterator(), ",")); sb.append(" ) VALUES ( "); sb.append(StringUtils.join(insertPlaceholderColumns.iterator(), ",")); sb.append(" ) "); return sb.toString(); } }
SpringNamedSqlGenerator implements SqlGenerator { public String getInsertSql() { StringBuilder sb = new StringBuilder("INSERT INTO ").append(getTableName()).append(" ("); List<String> insertColumns = new ArrayList(getColumns().size()); List<String> insertPlaceholderColumns = new ArrayList(getColumns().size()); for(int i = 0; i < getColumns().size(); i++) { Column c = getColumns().get(i); if(c.isInsertable()) { insertColumns.add(c.getSqlName()); insertPlaceholderColumns.add(getColumnPlaceholder(c)); } } sb.append(StringUtils.join(insertColumns.iterator(), ",")); sb.append(" ) VALUES ( "); sb.append(StringUtils.join(insertPlaceholderColumns.iterator(), ",")); sb.append(" ) "); return sb.toString(); } SpringNamedSqlGenerator(Table table); }
SpringNamedSqlGenerator implements SqlGenerator { public String getInsertSql() { StringBuilder sb = new StringBuilder("INSERT INTO ").append(getTableName()).append(" ("); List<String> insertColumns = new ArrayList(getColumns().size()); List<String> insertPlaceholderColumns = new ArrayList(getColumns().size()); for(int i = 0; i < getColumns().size(); i++) { Column c = getColumns().get(i); if(c.isInsertable()) { insertColumns.add(c.getSqlName()); insertPlaceholderColumns.add(getColumnPlaceholder(c)); } } sb.append(StringUtils.join(insertColumns.iterator(), ",")); sb.append(" ) VALUES ( "); sb.append(StringUtils.join(insertPlaceholderColumns.iterator(), ",")); sb.append(" ) "); return sb.toString(); } SpringNamedSqlGenerator(Table table); List<Column> getColumns(); String getTableName(); List<Column> getPrimaryKeyColumns(); Table getTable(); boolean isMultiPrimaryKey(); boolean isSinglePrimaryKey(); String getInsertSql(); String getDeleteByPkSql(); String getSelectByPkSql(); String getUpdateByPkSql(); String getDeleteByMultiPkSql(); String getDeleteBySinglePkSql(); String getSelectByMultiPkSql(); String getSelectBySinglePkSql(); String getColumnsSql(); String getColumnsSql(String columnPrefix); }
SpringNamedSqlGenerator implements SqlGenerator { public String getInsertSql() { StringBuilder sb = new StringBuilder("INSERT INTO ").append(getTableName()).append(" ("); List<String> insertColumns = new ArrayList(getColumns().size()); List<String> insertPlaceholderColumns = new ArrayList(getColumns().size()); for(int i = 0; i < getColumns().size(); i++) { Column c = getColumns().get(i); if(c.isInsertable()) { insertColumns.add(c.getSqlName()); insertPlaceholderColumns.add(getColumnPlaceholder(c)); } } sb.append(StringUtils.join(insertColumns.iterator(), ",")); sb.append(" ) VALUES ( "); sb.append(StringUtils.join(insertPlaceholderColumns.iterator(), ",")); sb.append(" ) "); return sb.toString(); } SpringNamedSqlGenerator(Table table); List<Column> getColumns(); String getTableName(); List<Column> getPrimaryKeyColumns(); Table getTable(); boolean isMultiPrimaryKey(); boolean isSinglePrimaryKey(); String getInsertSql(); String getDeleteByPkSql(); String getSelectByPkSql(); String getUpdateByPkSql(); String getDeleteByMultiPkSql(); String getDeleteBySinglePkSql(); String getSelectByMultiPkSql(); String getSelectBySinglePkSql(); String getColumnsSql(); String getColumnsSql(String columnPrefix);  }