Search in sources :

Example 6 with QSurvey

use of com.querydsl.sql.domain.QSurvey in project querydsl by querydsl.

the class DeleteBase method delete_with_subQuery_exists2.

@Test
public void delete_with_subQuery_exists2() {
    QSurvey survey1 = new QSurvey("s1");
    QEmployee employee = new QEmployee("e");
    SQLDeleteClause delete = delete(survey1);
    delete.where(survey1.name.eq("XXX"), query().from(employee).where(survey1.name.eq(employee.lastname)).exists());
    assertEquals(0, delete.execute());
}
Also used : SQLDeleteClause(com.querydsl.sql.dml.SQLDeleteClause) QSurvey(com.querydsl.sql.domain.QSurvey) QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test)

Example 7 with QSurvey

use of com.querydsl.sql.domain.QSurvey in project querydsl by querydsl.

the class SerializationTest method with_complex.

@Test
public void with_complex() {
    QSurvey s = new QSurvey("s");
    SQLQuery<?> q = new SQLQuery<Void>();
    q.with(s, s.id, s.name).as(select(survey.id, survey.name).from(survey)).select(s.id, s.name, survey.id, survey.name).from(s, survey);
    assertEquals("with s (ID, NAME) as (select SURVEY.ID, SURVEY.NAME\n" + "from SURVEY SURVEY)\n" + "select s.ID, s.NAME, SURVEY.ID, SURVEY.NAME\n" + "from s s, SURVEY SURVEY", q.toString());
}
Also used : QSurvey(com.querydsl.sql.domain.QSurvey) Test(org.junit.Test)

Example 8 with QSurvey

use of com.querydsl.sql.domain.QSurvey in project querydsl by querydsl.

the class SerializationTest method rightJoin.

@Test
public void rightJoin() {
    SQLQuery<?> query = new SQLQuery<Void>(connection, SQLTemplates.DEFAULT);
    query.from(new QSurvey("s1")).rightJoin(new QSurvey("s2"));
    assertEquals("from SURVEY s1\nright join SURVEY s2", query.toString());
}
Also used : QSurvey(com.querydsl.sql.domain.QSurvey) Test(org.junit.Test)

Example 9 with QSurvey

use of com.querydsl.sql.domain.QSurvey in project querydsl by querydsl.

the class SerializationTest method with.

@Test
public void with() {
    QSurvey survey2 = new QSurvey("survey2");
    SQLQuery<?> q = new SQLQuery<Void>();
    q.with(survey, survey.id, survey.name).as(select(survey2.id, survey2.name).from(survey2));
    assertEquals("with SURVEY (ID, NAME) as (select survey2.ID, survey2.NAME\n" + "from SURVEY survey2)\n\n" + "from dual", q.toString());
}
Also used : QSurvey(com.querydsl.sql.domain.QSurvey) Test(org.junit.Test)

Example 10 with QSurvey

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