Search in sources :

Example 1 with QEmployee

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

the class ListSubQueryTest method hashCode2.

@Test
public void hashCode2() {
    QSurvey survey = new QSurvey("entity");
    QEmployee employee = new QEmployee("entity");
    SubQueryExpression<Integer> query1 = select(survey.id).from(survey);
    SubQueryExpression<Integer> query2 = select(employee.id).from(employee);
    Set<SubQueryExpression<Integer>> queries = Sets.newHashSet();
    queries.add(query1);
    queries.add(query2);
    assertEquals(1, queries.size());
}
Also used : SubQueryExpression(com.querydsl.core.types.SubQueryExpression) QSurvey(com.querydsl.sql.domain.QSurvey) QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test)

Example 2 with QEmployee

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

the class DeleteBase method delete_with_subQuery_exists.

@Test
public void delete_with_subQuery_exists() {
    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.id.eq(employee.id)).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 3 with QEmployee

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

the class DeleteBase method delete_with_subQuery_exists_Params.

@Test
public void delete_with_subQuery_exists_Params() {
    QSurvey survey1 = new QSurvey("s1");
    QEmployee employee = new QEmployee("e");
    Param<Integer> param = new Param<Integer>(Integer.class, "param");
    SQLQuery<?> sq = query().from(employee).where(employee.id.eq(param));
    sq.set(param, -12478923);
    SQLDeleteClause delete = delete(survey1);
    delete.where(survey1.name.eq("XXX"), sq.exists());
    assertEquals(0, delete.execute());
}
Also used : SQLDeleteClause(com.querydsl.sql.dml.SQLDeleteClause) Param(com.querydsl.core.types.dsl.Param) QSurvey(com.querydsl.sql.domain.QSurvey) QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test)

Example 4 with QEmployee

use of com.querydsl.sql.domain.QEmployee 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 5 with QEmployee

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

the class SubqueriesBase method keys.

@Test
@ExcludeIn({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, SQLITE, SQLSERVER })
public void keys() {
    QEmployee employee2 = new QEmployee("employee2");
    ForeignKey<Employee> nameKey1 = new ForeignKey<Employee>(employee, ImmutableList.of(employee.firstname, employee.lastname), ImmutableList.of("a", "b"));
    ForeignKey<Employee> nameKey2 = new ForeignKey<Employee>(employee, ImmutableList.of(employee.firstname, employee.lastname), ImmutableList.of("a", "b"));
    query().from(employee).where(nameKey1.in(query().from(employee2).select(nameKey2.getProjection()))).select(employee.id).fetch();
}
Also used : Employee(com.querydsl.sql.domain.Employee) QEmployee(com.querydsl.sql.domain.QEmployee) QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test) ExcludeIn(com.querydsl.core.testutil.ExcludeIn)

Aggregations

QEmployee (com.querydsl.sql.domain.QEmployee)27 Test (org.junit.Test)27 QSurvey (com.querydsl.sql.domain.QSurvey)10 SQLDeleteClause (com.querydsl.sql.dml.SQLDeleteClause)6 ExcludeIn (com.querydsl.core.testutil.ExcludeIn)4 SQLUpdateClause (com.querydsl.sql.dml.SQLUpdateClause)4 Tuple (com.querydsl.core.Tuple)3 QueryMetadata (com.querydsl.core.QueryMetadata)2 Param (com.querydsl.core.types.dsl.Param)2 Employee (com.querydsl.sql.domain.Employee)2 Connection (java.sql.Connection)2 QueryModifiers (com.querydsl.core.QueryModifiers)1 QueryMixin (com.querydsl.core.support.QueryMixin)1 IncludeIn (com.querydsl.core.testutil.IncludeIn)1 SubQueryExpression (com.querydsl.core.types.SubQueryExpression)1 Ignore (org.junit.Ignore)1