q.select(table.getColumns());
q.from(table, "a");
q.where(table.getColumnByName("CUSTOMERNUMBER"), OperatorType.EQUALS_TO, queryParameter);
q.where(table.getColumnByName("CUSTOMERNAME"), OperatorType.EQUALS_TO, queryParameter);
final CompiledQuery compiledQuery = dataContext.compileQuery(q);
final JdbcCompiledQuery jdbcCompiledQuery = (JdbcCompiledQuery) compiledQuery;
assertEquals(0, jdbcCompiledQuery.getActiveLeases());
assertEquals(0, jdbcCompiledQuery.getIdleLeases());
String compliedQueryString = compiledQuery.toSql();
assertEquals(
"SELECT a._CUSTOMERNUMBER_, a._CUSTOMERNAME_, a._CONTACTLASTNAME_, a._CONTACTFIRSTNAME_, a._PHONE_, a._ADDRESSLINE1_, a._ADDRESSLINE2_, a._CITY_, "
+ "a._STATE_, a._POSTALCODE_, a._COUNTRY_, a._SALESREPEMPLOYEENUMBER_, a._CREDITLIMIT_ FROM PUBLIC._CUSTOMERS_ a WHERE a._CUSTOMERNUMBER_ = ? "
+ "AND a._CUSTOMERNAME_ = ?", compliedQueryString.replace('\"', '_'));
DataSet result1 = dataContext.executeQuery(compiledQuery, new Object[] { 103, "Atelier graphique" });
assertTrue(result1.next());
assertEquals(
"Row[values=[103, Atelier graphique, Schmitt, Carine, 40.32.2555, 54, rue Royale, null, Nantes, null, 44000, France, 1370, 21000.0]]",
result1.getRow().toString());
assertFalse(result1.next());
assertEquals(1, jdbcCompiledQuery.getActiveLeases());
assertEquals(0, jdbcCompiledQuery.getIdleLeases());
DataSet result2 = dataContext.executeQuery(compiledQuery, new Object[] { 103, "Atelier graphique" });
assertEquals(2, jdbcCompiledQuery.getActiveLeases());
assertEquals(0, jdbcCompiledQuery.getIdleLeases());
result1.close();
assertEquals(1, jdbcCompiledQuery.getActiveLeases());
assertEquals(1, jdbcCompiledQuery.getIdleLeases());
result2.close();
assertEquals(0, jdbcCompiledQuery.getActiveLeases());
assertEquals(2, jdbcCompiledQuery.getIdleLeases());
compiledQuery.close();
assertEquals(0, jdbcCompiledQuery.getActiveLeases());
assertEquals(0, jdbcCompiledQuery.getIdleLeases());
}