@Test public void deleteSql() { System.out.println(t.getDeleteByMultiPkSql()); assertEquals("DELETE FROM user WHERE user_id = :userId", t.getDeleteByMultiPkSql()); assertEquals("DELETE FROM user WHERE user_id = :userId AND group_id = :groupId", multiKeySqlGenerator.getDeleteByMultiPkSql()); }
public String getDeleteByMultiPkSql() { StringBuilder sb = new StringBuilder("DELETE FROM ").append(getTableName()); sb.append(" WHERE "); List<Column> primaryKeyColumns = getPrimaryKeyColumns(); for(int i = 0; i < primaryKeyColumns.size(); i++) { Column c = primaryKeyColumns.get(i); sb.append(c.getSqlName()+" = "+getColumnPlaceholder(c)); if(i < primaryKeyColumns.size() - 1) sb.append(" AND "); } return sb.toString(); }
SpringNamedSqlGenerator implements SqlGenerator { public String getDeleteByMultiPkSql() { StringBuilder sb = new StringBuilder("DELETE FROM ").append(getTableName()); sb.append(" WHERE "); List<Column> primaryKeyColumns = getPrimaryKeyColumns(); for(int i = 0; i < primaryKeyColumns.size(); i++) { Column c = primaryKeyColumns.get(i); sb.append(c.getSqlName()+" = "+getColumnPlaceholder(c)); if(i < primaryKeyColumns.size() - 1) sb.append(" AND "); } return sb.toString(); } }
SpringNamedSqlGenerator implements SqlGenerator { public String getDeleteByMultiPkSql() { StringBuilder sb = new StringBuilder("DELETE FROM ").append(getTableName()); sb.append(" WHERE "); List<Column> primaryKeyColumns = getPrimaryKeyColumns(); for(int i = 0; i < primaryKeyColumns.size(); i++) { Column c = primaryKeyColumns.get(i); sb.append(c.getSqlName()+" = "+getColumnPlaceholder(c)); if(i < primaryKeyColumns.size() - 1) sb.append(" AND "); } return sb.toString(); } SpringNamedSqlGenerator(Table table); }
SpringNamedSqlGenerator implements SqlGenerator { public String getDeleteByMultiPkSql() { StringBuilder sb = new StringBuilder("DELETE FROM ").append(getTableName()); sb.append(" WHERE "); List<Column> primaryKeyColumns = getPrimaryKeyColumns(); for(int i = 0; i < primaryKeyColumns.size(); i++) { Column c = primaryKeyColumns.get(i); sb.append(c.getSqlName()+" = "+getColumnPlaceholder(c)); if(i < primaryKeyColumns.size() - 1) sb.append(" AND "); } 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 getDeleteByMultiPkSql() { StringBuilder sb = new StringBuilder("DELETE FROM ").append(getTableName()); sb.append(" WHERE "); List<Column> primaryKeyColumns = getPrimaryKeyColumns(); for(int i = 0; i < primaryKeyColumns.size(); i++) { Column c = primaryKeyColumns.get(i); sb.append(c.getSqlName()+" = "+getColumnPlaceholder(c)); if(i < primaryKeyColumns.size() - 1) sb.append(" AND "); } 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);  }