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);
}
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 SQLQueryTest method noConnection.
@Test(expected = IllegalStateException.class)
public void noConnection() {
QSurvey survey = QSurvey.survey;
SQLExpressions.select(survey.id).from(survey).fetch();
}
use of com.querydsl.sql.domain.QSurvey in project querydsl by querydsl.
the class UpdateBase method update_with_subQuery_exists2.
@Test
public void update_with_subQuery_exists2() {
QSurvey survey1 = new QSurvey("s1");
QEmployee employee = new QEmployee("e");
SQLUpdateClause update = update(survey1);
update.set(survey1.name, "AA");
update.where(selectOne().from(employee).where(survey1.name.eq(employee.lastname)).exists());
assertEquals(0, update.execute());
}
Aggregations