mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-13 21:01:01 +08:00
Merge pull request #1751 from querydsl/sqlqueryfactory
Unify SQLQueryFactory signatures
This commit is contained in:
commit
9e2a6f7ec0
@ -17,6 +17,7 @@ import java.sql.Connection;
|
||||
|
||||
import javax.inject.Provider;
|
||||
|
||||
import com.querydsl.core.Tuple;
|
||||
import com.querydsl.core.types.Expression;
|
||||
import com.querydsl.core.types.Path;
|
||||
import com.querydsl.core.types.SubQueryExpression;
|
||||
@ -90,4 +91,61 @@ public abstract class AbstractSQLQueryFactory<Q extends SQLCommonQuery<?>> imple
|
||||
return connection.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new SQL query with the given projection
|
||||
*
|
||||
* @param expr projection
|
||||
* @param <T> type of the projection
|
||||
* @return select(expr)
|
||||
*/
|
||||
public abstract <T> AbstractSQLQuery<T, ?> select(Expression<T> expr);
|
||||
|
||||
/**
|
||||
* Create a new SQL query with the given projection
|
||||
*
|
||||
* @param exprs projection
|
||||
* @return select(exprs)
|
||||
*/
|
||||
public abstract AbstractSQLQuery<Tuple, ?> select(Expression<?>... exprs);
|
||||
|
||||
/**
|
||||
* Create a new SQL query with the given projection
|
||||
*
|
||||
* @param expr distinct projection
|
||||
* @param <T> type of the projection
|
||||
* @return select(distinct expr)
|
||||
*/
|
||||
public abstract <T> AbstractSQLQuery<T, ?> selectDistinct(Expression<T> expr);
|
||||
|
||||
/**
|
||||
* Create a new SQL query with the given projection
|
||||
*
|
||||
* @param exprs distinct projection
|
||||
* @return select(distinct exprs)
|
||||
*/
|
||||
public abstract AbstractSQLQuery<Tuple, ?> selectDistinct(Expression<?>... exprs);
|
||||
|
||||
/**
|
||||
* Create a new SQL query with zero as the projection
|
||||
*
|
||||
* @return select(0)
|
||||
*/
|
||||
public abstract AbstractSQLQuery<Integer, ?> selectZero();
|
||||
|
||||
/**
|
||||
* Create a new SQL query with one as the projection
|
||||
*
|
||||
* @return select(1)
|
||||
*/
|
||||
public abstract AbstractSQLQuery<Integer, ?> selectOne();
|
||||
|
||||
/**
|
||||
* Create a new SQL query with the given projection and source
|
||||
*
|
||||
* @param expr query source and projection
|
||||
* @param <T> type of the projection
|
||||
* @return select(expr).from(expr)
|
||||
*/
|
||||
public abstract <T> AbstractSQLQuery<T, ?> selectFrom(RelationalPath<T> expr);
|
||||
|
||||
}
|
||||
|
||||
@ -74,73 +74,37 @@ public class SQLQueryFactory extends AbstractSQLQueryFactory<SQLQuery<?>> {
|
||||
return new SQLQuery<Void>(connection, configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new SQLQuery instance with the given projection
|
||||
*
|
||||
* @param expr projection
|
||||
* @param <T>
|
||||
* @return select(expr)
|
||||
*/
|
||||
@Override
|
||||
public <T> SQLQuery<T> select(Expression<T> expr) {
|
||||
return query().select(expr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new SQLQuery instance with the given projection
|
||||
*
|
||||
* @param exprs projection
|
||||
* @return select(exprs)
|
||||
*/
|
||||
@Override
|
||||
public SQLQuery<Tuple> select(Expression<?>... exprs) {
|
||||
return query().select(exprs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new SQLQuery instance with the given projection
|
||||
*
|
||||
* @param expr distinct projection
|
||||
* @param <T>
|
||||
* @return select(distinct expr)
|
||||
*/
|
||||
@Override
|
||||
public <T> SQLQuery<T> selectDistinct(Expression<T> expr) {
|
||||
return query().select(expr).distinct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new SQLQuery instance with the given projection
|
||||
*
|
||||
* @param exprs distinct projection
|
||||
* @return select(distinct exprs)
|
||||
*/
|
||||
@Override
|
||||
public SQLQuery<Tuple> selectDistinct(Expression<?>... exprs) {
|
||||
return query().select(exprs).distinct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new SQLQuery instance with zero as the projection
|
||||
*
|
||||
* @return select(0)
|
||||
*/
|
||||
@Override
|
||||
public SQLQuery<Integer> selectZero() {
|
||||
return select(Expressions.ZERO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new SQLQuery instance with one as the projection
|
||||
*
|
||||
* @return select(1)
|
||||
*/
|
||||
@Override
|
||||
public SQLQuery<Integer> selectOne() {
|
||||
return select(Expressions.ONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new SQLQuery instance with the given projection and source
|
||||
*
|
||||
* @param expr query source and projection
|
||||
* @param <T>
|
||||
* @return select(expr).from(expr)
|
||||
*/
|
||||
@Override
|
||||
public <T> SQLQuery<T> selectFrom(RelationalPath<T> expr) {
|
||||
return select(expr).from(expr);
|
||||
}
|
||||
|
||||
@ -17,10 +17,10 @@ import java.sql.Connection;
|
||||
|
||||
import javax.inject.Provider;
|
||||
|
||||
import com.querydsl.sql.AbstractSQLQueryFactory;
|
||||
import com.querydsl.sql.Configuration;
|
||||
import com.querydsl.sql.SQLServerTemplates;
|
||||
import com.querydsl.sql.SQLTemplates;
|
||||
import com.querydsl.core.Tuple;
|
||||
import com.querydsl.core.types.Expression;
|
||||
import com.querydsl.core.types.dsl.Expressions;
|
||||
import com.querydsl.sql.*;
|
||||
|
||||
/**
|
||||
* SQL Server specific implementation of SQLQueryFactory
|
||||
@ -47,4 +47,39 @@ public class SQLServerQueryFactory extends AbstractSQLQueryFactory<SQLServerQuer
|
||||
return new SQLServerQuery<Void>(connection, configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> SQLServerQuery<T> select(Expression<T> expr) {
|
||||
return query().select(expr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SQLServerQuery<Tuple> select(Expression<?>... exprs) {
|
||||
return query().select(exprs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> SQLServerQuery<T> selectDistinct(Expression<T> expr) {
|
||||
return query().select(expr).distinct();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SQLServerQuery<Tuple> selectDistinct(Expression<?>... exprs) {
|
||||
return query().select(exprs).distinct();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SQLServerQuery<Integer> selectZero() {
|
||||
return select(Expressions.ZERO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SQLServerQuery<Integer> selectOne() {
|
||||
return select(Expressions.ONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> SQLServerQuery<T> selectFrom(RelationalPath<T> expr) {
|
||||
return select(expr).from(expr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -18,8 +18,10 @@ import java.sql.Connection;
|
||||
import javax.inject.Provider;
|
||||
|
||||
import com.querydsl.core.QueryFlag.Position;
|
||||
import com.querydsl.core.Tuple;
|
||||
import com.querydsl.core.types.Expression;
|
||||
import com.querydsl.core.types.ExpressionUtils;
|
||||
import com.querydsl.core.types.dsl.Expressions;
|
||||
import com.querydsl.sql.*;
|
||||
import com.querydsl.sql.dml.SQLInsertClause;
|
||||
|
||||
@ -90,4 +92,39 @@ public class MySQLQueryFactory extends AbstractSQLQueryFactory<MySQLQuery<?>> {
|
||||
return new MySQLReplaceClause(connection.get(), configuration, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> MySQLQuery<T> select(Expression<T> expr) {
|
||||
return query().select(expr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MySQLQuery<Tuple> select(Expression<?>... exprs) {
|
||||
return query().select(exprs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> MySQLQuery<T> selectDistinct(Expression<T> expr) {
|
||||
return query().select(expr).distinct();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MySQLQuery<Tuple> selectDistinct(Expression<?>... exprs) {
|
||||
return query().select(exprs).distinct();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MySQLQuery<Integer> selectZero() {
|
||||
return select(Expressions.ZERO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MySQLQuery<Integer> selectOne() {
|
||||
return select(Expressions.ONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> MySQLQuery<T> selectFrom(RelationalPath<T> expr) {
|
||||
return select(expr).from(expr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -17,10 +17,10 @@ import java.sql.Connection;
|
||||
|
||||
import javax.inject.Provider;
|
||||
|
||||
import com.querydsl.sql.AbstractSQLQueryFactory;
|
||||
import com.querydsl.sql.Configuration;
|
||||
import com.querydsl.sql.OracleTemplates;
|
||||
import com.querydsl.sql.SQLTemplates;
|
||||
import com.querydsl.core.Tuple;
|
||||
import com.querydsl.core.types.Expression;
|
||||
import com.querydsl.core.types.dsl.Expressions;
|
||||
import com.querydsl.sql.*;
|
||||
|
||||
/**
|
||||
* Oracle specific implementation of SQLQueryFactory
|
||||
@ -47,4 +47,39 @@ public class OracleQueryFactory extends AbstractSQLQueryFactory<OracleQuery<?>>
|
||||
return new OracleQuery<Void>(connection, configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> OracleQuery<T> select(Expression<T> expr) {
|
||||
return query().select(expr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OracleQuery<Tuple> select(Expression<?>... exprs) {
|
||||
return query().select(exprs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> OracleQuery<T> selectDistinct(Expression<T> expr) {
|
||||
return query().select(expr).distinct();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OracleQuery<Tuple> selectDistinct(Expression<?>... exprs) {
|
||||
return query().select(exprs).distinct();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OracleQuery<Integer> selectZero() {
|
||||
return select(Expressions.ZERO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OracleQuery<Integer> selectOne() {
|
||||
return select(Expressions.ONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> OracleQuery<T> selectFrom(RelationalPath<T> expr) {
|
||||
return select(expr).from(expr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -17,10 +17,10 @@ import java.sql.Connection;
|
||||
|
||||
import javax.inject.Provider;
|
||||
|
||||
import com.querydsl.sql.AbstractSQLQueryFactory;
|
||||
import com.querydsl.sql.Configuration;
|
||||
import com.querydsl.sql.PostgreSQLTemplates;
|
||||
import com.querydsl.sql.SQLTemplates;
|
||||
import com.querydsl.core.Tuple;
|
||||
import com.querydsl.core.types.Expression;
|
||||
import com.querydsl.core.types.dsl.Expressions;
|
||||
import com.querydsl.sql.*;
|
||||
|
||||
/**
|
||||
* PostgreSQL specific implementation of SQLQueryFactory
|
||||
@ -47,5 +47,40 @@ public class PostgreSQLQueryFactory extends AbstractSQLQueryFactory<PostgreSQLQu
|
||||
return new PostgreSQLQuery<Void>(connection, configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> PostgreSQLQuery<T> select(Expression<T> expr) {
|
||||
return query().select(expr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PostgreSQLQuery<Tuple> select(Expression<?>... exprs) {
|
||||
return query().select(exprs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> PostgreSQLQuery<T> selectDistinct(Expression<T> expr) {
|
||||
return query().select(expr).distinct();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PostgreSQLQuery<Tuple> selectDistinct(Expression<?>... exprs) {
|
||||
return query().select(exprs).distinct();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PostgreSQLQuery<Integer> selectZero() {
|
||||
return select(Expressions.ZERO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PostgreSQLQuery<Integer> selectOne() {
|
||||
return select(Expressions.ONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> PostgreSQLQuery<T> selectFrom(RelationalPath<T> expr) {
|
||||
return select(expr).from(expr);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -17,10 +17,10 @@ import java.sql.Connection;
|
||||
|
||||
import javax.inject.Provider;
|
||||
|
||||
import com.querydsl.sql.AbstractSQLQueryFactory;
|
||||
import com.querydsl.sql.Configuration;
|
||||
import com.querydsl.sql.SQLTemplates;
|
||||
import com.querydsl.sql.TeradataTemplates;
|
||||
import com.querydsl.core.Tuple;
|
||||
import com.querydsl.core.types.Expression;
|
||||
import com.querydsl.core.types.dsl.Expressions;
|
||||
import com.querydsl.sql.*;
|
||||
|
||||
/**
|
||||
* Teradata specific implementation of SQLQueryFactory
|
||||
@ -47,5 +47,40 @@ public class TeradataQueryFactory extends AbstractSQLQueryFactory<TeradataQuery<
|
||||
return new TeradataQuery<Void>(connection, configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> TeradataQuery<T> select(Expression<T> expr) {
|
||||
return query().select(expr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TeradataQuery<Tuple> select(Expression<?>... exprs) {
|
||||
return query().select(exprs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> TeradataQuery<T> selectDistinct(Expression<T> expr) {
|
||||
return query().select(expr).distinct();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TeradataQuery<Tuple> selectDistinct(Expression<?>... exprs) {
|
||||
return query().select(exprs).distinct();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TeradataQuery<Integer> selectZero() {
|
||||
return select(Expressions.ZERO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TeradataQuery<Integer> selectOne() {
|
||||
return select(Expressions.ONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> TeradataQuery<T> selectFrom(RelationalPath<T> expr) {
|
||||
return select(expr).from(expr);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user