@Test public void testGenerateSelect() throws Exception { Assert.assertTrue("select col1,col2,col3 from myCatalog.mySchema.myTable".equals( generator.generateSelect(topic, null, fieldNames).getSqlText())); FilterCriteria fCrit1 = createFilterCriteria("myCol1", FilterCriteria.Operation.EQUAL, "fu"); FilterCriteria fCrit2 = createFilterCriteria("myCol2", FilterCriteria.Operation.EQUAL, "bar"); CompositeCriteria cCrit2 = createCompositCriteria(new Criteria[]{fCrit1,fCrit2}, CompositeCriteria.Operator.OR); CompositeCriteria compositeCriteria = createCompositCriteria(new Criteria[]{fCrit1,fCrit2,cCrit2}, CompositeCriteria.Operator.AND); System.out.println(generator.generateSelect(topic, compositeCriteria, fieldNames)); SqlStatement stmt = generator.generateSelect(topic, compositeCriteria, fieldNames); Assert.assertTrue("select col1,col2,col3 from myCatalog.mySchema.myTable where myCol1 =? and myCol2 =? and (myCol1 =? or myCol2 =?)".equals(stmt.getSqlText())); Assert.assertTrue(stmt.getHostVariableValueList().size()==4); Assert.assertTrue("fu".equals(stmt.getHostVariableValueList().get(0))); Assert.assertTrue("bar".equals(stmt.getHostVariableValueList().get(1))); Assert.assertTrue("fu".equals(stmt.getHostVariableValueList().get(2))); Assert.assertTrue("bar".equals(stmt.getHostVariableValueList().get(3))); }
public SqlStatement generateSelect(Topic topic, CompositeCriteria searchCriteria, String[] fieldNames) { StringBuilder builder = new StringBuilder(this.generateSelectClause(fieldNames)); builder.append(" "); builder.append(this.generateFromClause(topic, LockIntent.NONE)); SqlStatement statement = null; if (searchCriteria != null) { builder.append(" "); statement = this.generateWhereClause(searchCriteria); builder.append(statement.getSqlText()); } else { statement = new SqlStatement(); } statement.setSqlText(builder.toString()); return statement; }
DefaultSqlGenerator implements SqlGenerator { public SqlStatement generateSelect(Topic topic, CompositeCriteria searchCriteria, String[] fieldNames) { StringBuilder builder = new StringBuilder(this.generateSelectClause(fieldNames)); builder.append(" "); builder.append(this.generateFromClause(topic, LockIntent.NONE)); SqlStatement statement = null; if (searchCriteria != null) { builder.append(" "); statement = this.generateWhereClause(searchCriteria); builder.append(statement.getSqlText()); } else { statement = new SqlStatement(); } statement.setSqlText(builder.toString()); return statement; } }
DefaultSqlGenerator implements SqlGenerator { public SqlStatement generateSelect(Topic topic, CompositeCriteria searchCriteria, String[] fieldNames) { StringBuilder builder = new StringBuilder(this.generateSelectClause(fieldNames)); builder.append(" "); builder.append(this.generateFromClause(topic, LockIntent.NONE)); SqlStatement statement = null; if (searchCriteria != null) { builder.append(" "); statement = this.generateWhereClause(searchCriteria); builder.append(statement.getSqlText()); } else { statement = new SqlStatement(); } statement.setSqlText(builder.toString()); return statement; } DefaultSqlGenerator(); }
DefaultSqlGenerator implements SqlGenerator { public SqlStatement generateSelect(Topic topic, CompositeCriteria searchCriteria, String[] fieldNames) { StringBuilder builder = new StringBuilder(this.generateSelectClause(fieldNames)); builder.append(" "); builder.append(this.generateFromClause(topic, LockIntent.NONE)); SqlStatement statement = null; if (searchCriteria != null) { builder.append(" "); statement = this.generateWhereClause(searchCriteria); builder.append(statement.getSqlText()); } else { statement = new SqlStatement(); } statement.setSqlText(builder.toString()); return statement; } DefaultSqlGenerator(); SqlStatement generateSelect(Topic topic, CompositeCriteria searchCriteria,
			String[] fieldNames); }
DefaultSqlGenerator implements SqlGenerator { public SqlStatement generateSelect(Topic topic, CompositeCriteria searchCriteria, String[] fieldNames) { StringBuilder builder = new StringBuilder(this.generateSelectClause(fieldNames)); builder.append(" "); builder.append(this.generateFromClause(topic, LockIntent.NONE)); SqlStatement statement = null; if (searchCriteria != null) { builder.append(" "); statement = this.generateWhereClause(searchCriteria); builder.append(statement.getSqlText()); } else { statement = new SqlStatement(); } statement.setSqlText(builder.toString()); return statement; } DefaultSqlGenerator(); SqlStatement generateSelect(Topic topic, CompositeCriteria searchCriteria,
			String[] fieldNames);  }