Search in sources :

Example 11 with QSurvey

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

the class SerializationTest method with_tuple2.

@Test
public void with_tuple2() {
    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 12 with QSurvey

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

the class SerializationTest method delete_with_subQuery_exists.

@Test
public void delete_with_subQuery_exists() {
    QSurvey survey1 = new QSurvey("s1");
    QEmployee employee = new QEmployee("e");
    SQLDeleteClause delete = new SQLDeleteClause(connection, SQLTemplates.DEFAULT, survey1);
    delete.where(survey1.name.eq("XXX"), selectOne().from(employee).where(survey1.id.eq(employee.id)).exists());
    assertEquals("delete from SURVEY\n" + "where SURVEY.NAME = ? and exists (select 1\n" + "from EMPLOYEE e\n" + "where SURVEY.ID = e.ID)", delete.toString());
}
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 13 with QSurvey

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

the class SerializationTest method innerJoin.

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

Example 14 with QSurvey

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

the class SerializationTest method leftJoin.

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

Example 15 with QSurvey

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());
}
Also used : 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