SpringNamedSqlGenerator implements SqlGenerator { public String getSelectBySinglePkSql() { checkIsSinglePrimaryKey(); List<Column> primaryKeyColumns = getPrimaryKeyColumns(); StringBuilder sb = new StringBuilder("SELECT "+getColumnsSql()+" FROM " + getTableName()+" WHERE "); sb.append(getSinglePrimaryKeyWhere()); 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);  }
@Test public void getSelectBySinglePkSql() { System.out.println(t.getSelectBySinglePkSql()); assertEquals("SELECT user_id userId,user_name userName,pwd pwd FROM user WHERE user_id = ?", t.getSelectBySinglePkSql()); try { multiKeySqlGenerator.getSelectBySinglePkSql(); fail(); }catch(IllegalStateException espected) { assertNotNull(espected); } }