Skip to content

Commit

Permalink
Deprecate getResults with arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
timowest committed Nov 26, 2015
1 parent 51b8f3f commit 8a25382
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
17 changes: 15 additions & 2 deletions querydsl-sql/src/main/java/com/querydsl/sql/AbstractSQLQuery.java
Expand Up @@ -247,14 +247,27 @@ protected void endContext(SQLListenerContext context) {
}

/**
* Get the results as an JDBC result set
* Get the results as an JDBC ResultSet
*
* @param exprs the expression arguments to retrieve
* @return results as ResultSet
* @deprecated Use @{code select(..)} to define the projection and {@code getResults()} to obtain
* the result set
*/
@Deprecated
public ResultSet getResults(Expression<?>... exprs) {
queryMixin.setProjection(exprs);
if (exprs.length > 0) {
queryMixin.setProjection(exprs);
}
return getResults();
}

/**
* Get the results as an JDBC ResultSet
*
* @return results as ResultSet
*/
public ResultSet getResults() {
SQLListenerContextImpl context = startContext(connection(), queryMixin.getMetadata());
String queryString = null;
List<Object> constants = ImmutableList.of();
Expand Down
Expand Up @@ -158,8 +158,8 @@ public void run(int times) throws Exception {
for (int i = 0; i < times; i++) {
QCompanies companies = QCompanies.companies;
SQLQuery<?> query = new SQLQuery<Void>(conn, conf);
ResultSet rs = query.from(companies)
.where(companies.id.eq((long) i)).getResults(companies.name);
ResultSet rs = query.select(companies.name).from(companies)
.where(companies.id.eq((long) i)).getResults();
try {
while (rs.next()) {
rs.getString(1);
Expand Down
Expand Up @@ -756,7 +756,7 @@ public void Full_Join() throws SQLException {

@Test
public void GetResultSet() throws IOException, SQLException {
ResultSet results = query().from(survey).getResults(survey.id, survey.name);
ResultSet results = query().select(survey.id, survey.name).from(survey).getResults();
while (results.next()) {
assertNotNull(results.getObject(1));
assertNotNull(results.getObject(2));
Expand Down

0 comments on commit 8a25382

Please sign in to comment.