Search in sources :

Example 16 with QSurvey

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);
}
Also used : QSurvey(com.querydsl.sql.domain.QSurvey) Test(org.junit.Test)

Example 17 with QSurvey

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);
}
Also used : QSurvey(com.querydsl.sql.domain.QSurvey) Test(org.junit.Test)

Example 18 with QSurvey

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());
}
Also used : QSurvey(com.querydsl.sql.domain.QSurvey) Test(org.junit.Test)

Example 19 with QSurvey

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();
}
Also used : QSurvey(com.querydsl.sql.domain.QSurvey) Test(org.junit.Test)

Example 20 with QSurvey

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());
}
Also used : SQLUpdateClause(com.querydsl.sql.dml.SQLUpdateClause) QSurvey(com.querydsl.sql.domain.QSurvey) QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test)

Aggregations

QSurvey (com.querydsl.sql.domain.QSurvey)34 Test (org.junit.Test)33 QEmployee (com.querydsl.sql.domain.QEmployee)10 SQLDeleteClause (com.querydsl.sql.dml.SQLDeleteClause)4 SQLUpdateClause (com.querydsl.sql.dml.SQLUpdateClause)4 SubQueryExpression (com.querydsl.core.types.SubQueryExpression)2 Param (com.querydsl.core.types.dsl.Param)2 BooleanBuilder (com.querydsl.core.BooleanBuilder)1 Tuple (com.querydsl.core.Tuple)1 IncludeIn (com.querydsl.core.testutil.IncludeIn)1 Path (com.querydsl.core.types.Path)1 QTuple (com.querydsl.core.types.QTuple)1 PathBuilder (com.querydsl.core.types.dsl.PathBuilder)1 SQLServerTemplates (com.querydsl.sql.SQLServerTemplates)1 Before (org.junit.Before)1 Ignore (org.junit.Ignore)1