querydsl/querydsl-sql/src/test/java/com/mysema/query/ExtendedSQLQuery.java
2011-01-25 15:41:52 +00:00

57 lines
1.8 KiB
Java

package com.mysema.query;
import java.sql.Connection;
import java.util.List;
import com.mysema.commons.lang.CloseableIterator;
import com.mysema.query.sql.AbstractSQLQuery;
import com.mysema.query.sql.Configuration;
import com.mysema.query.sql.SQLTemplates;
import com.mysema.query.types.Expression;
import com.mysema.query.types.FactoryExpression;
import com.mysema.query.types.QBean;
/**
* @author tiwe
*
*/
public class ExtendedSQLQuery extends AbstractSQLQuery<ExtendedSQLQuery>{
public ExtendedSQLQuery(SQLTemplates templates) {
super(null, new Configuration(templates), new DefaultQueryMetadata());
}
public ExtendedSQLQuery(Connection conn, SQLTemplates templates) {
super(conn, new Configuration(templates), new DefaultQueryMetadata());
}
public ExtendedSQLQuery(Connection conn, Configuration configuration) {
super(conn, configuration, new DefaultQueryMetadata());
}
public ExtendedSQLQuery(Connection conn, Configuration configuration, QueryMetadata metadata) {
super(conn, configuration, metadata);
}
public <T> CloseableIterator<T> iterate(Class<T> type, Expression<?>... exprs){
return iterate(createProjection(type, exprs));
}
public <T> T uniqueResult(Class<T> type, Expression<?>... exprs){
return uniqueResult(createProjection(type, exprs));
}
public <T> List<T> list(Class<T> type, Expression<?>... exprs){
return list(createProjection(type, exprs));
}
public <T> SearchResults<T> listResults(Class<T> type, Expression<?>... exprs){
return listResults(createProjection(type, exprs));
}
private <T> FactoryExpression<T> createProjection(Class<T> type, Expression<?>... exprs){
return new QBean<T>(type, exprs);
}
}