use of com.querydsl.sql.domain.QSurvey in project querydsl by querydsl.
the class MySQLQueryTest method syntax.
@Test
public void syntax() {
// SELECT
// [ALL | DISTINCT | DISTINCTROW ]
// [HIGH_PRIORITY]
query.highPriority();
// [STRAIGHT_JOIN]
query.straightJoin();
// [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
query.smallResult();
query.bigResult();
query.bufferResult();
// [SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS]
query.cache();
query.noCache();
query.calcFoundRows();
// select_expr [, select_expr ...]
// [FROM table_references
query.from(new QSurvey("survey2"));
// [WHERE where_condition]
query.where(survey.id.isNotNull());
// [GROUP BY {col_name | expr | position}
query.groupBy(survey.name);
// [ASC | DESC], ... [WITH ROLLUP]]
query.withRollup();
// [HAVING where_condition]
query.having(survey.name.isNull());
// [ORDER BY {col_name | expr | position}
// [ASC | DESC], ...]
query.orderBy(survey.name.asc());
// [LIMIT {[offset,] row_count | row_count OFFSET offset}]
query.limit(2);
query.offset(3);
// [PROCEDURE procedure_name(argument_list)]
// TODO
// [INTO OUTFILE 'file_name' export_options
// | INTO DUMPFILE 'file_name'
// | INTO var_name [, var_name]]
// [FOR UPDATE | LOCK IN SHARE MODE]]
query.forUpdate();
query.lockInShareMode();
}
use of com.querydsl.sql.domain.QSurvey in project querydsl by querydsl.
the class SQLSubQueryTest method validate.
@Test
public void validate() {
NumberPath<Long> operatorTotalPermits = Expressions.numberPath(Long.class, "operator_total_permits");
QSurvey survey = new QSurvey("survey");
// select survey.name, count(*) as operator_total_permits
// from survey
// where survey.name >= "A"
// group by survey.name
// order by operator_total_permits asc
// limit 10
Expression<?> e = select(survey.name, Wildcard.count.as(operatorTotalPermits)).from(survey).where(survey.name.goe("A")).groupBy(survey.name).orderBy(operatorTotalPermits.asc()).limit(10).as("top");
select(Wildcard.all).from(e);
}
use of com.querydsl.sql.domain.QSurvey in project querydsl by querydsl.
the class SQLSubQueryTest method union1_with.
@SuppressWarnings("unchecked")
@Test
public void union1_with() {
QSurvey survey1 = new QSurvey("survey1");
QSurvey survey2 = new QSurvey("survey2");
QSurvey survey3 = new QSurvey("survey3");
SQLQuery<Void> query = new SQLQuery<Void>();
query.with(survey1, select(survey1.all()).from(survey1));
query.union(select(survey2.all()).from(survey2), select(survey3.all()).from(survey3));
assertEquals("with survey1 as (select survey1.NAME, survey1.NAME2, survey1.ID\n" + "from SURVEY survey1)\n" + "(select survey2.NAME, survey2.NAME2, survey2.ID\n" + "from SURVEY survey2)\n" + "union\n" + "(select survey3.NAME, survey3.NAME2, survey3.ID\n" + "from SURVEY survey3)", query.toString());
}
use of com.querydsl.sql.domain.QSurvey in project querydsl by querydsl.
the class SQLSubQueryTest method complex.
@Test
public void complex() {
// related to #584795
QSurvey survey = new QSurvey("survey");
QEmployee emp1 = new QEmployee("emp1");
QEmployee emp2 = new QEmployee("emp2");
SubQueryExpression<?> subQuery = select(survey.id, emp2.firstname).from(survey).innerJoin(emp1).on(survey.id.eq(emp1.id)).innerJoin(emp2).on(emp1.superiorId.eq(emp2.superiorId), emp1.firstname.eq(emp2.firstname));
assertEquals(3, subQuery.getMetadata().getJoins().size());
}
use of com.querydsl.sql.domain.QSurvey in project querydsl by querydsl.
the class SQLSubQueryTest method union1.
@SuppressWarnings("unchecked")
@Test
public void union1() {
QSurvey survey = QSurvey.survey;
SubQueryExpression<Integer> q1 = select(survey.id).from(survey);
SubQueryExpression<Integer> q2 = select(survey.id).from(survey);
union(q1, q2);
union(q1);
}
Aggregations