use of com.querydsl.sql.domain.QEmployee in project querydsl by querydsl.
the class SQLSerializerTest method schemaInWhere.
@Test
public void schemaInWhere() {
Configuration derbyWithPrintSchema = new Configuration(DerbyTemplates.builder().printSchema().build());
QEmployee e = QEmployee.employee;
SQLDeleteClause delete = new SQLDeleteClause(EasyMock.createNiceMock(Connection.class), derbyWithPrintSchema, e);
delete.where(e.id.gt(100));
assertEquals("delete from \"PUBLIC\".EMPLOYEE\n" + "where \"PUBLIC\".EMPLOYEE.ID > ?", delete.toString());
}
use of com.querydsl.sql.domain.QEmployee 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());
}
use of com.querydsl.sql.domain.QEmployee in project querydsl by querydsl.
the class SQLSubQueryTest method list_entity.
@Test
public void list_entity() {
QEmployee employee2 = new QEmployee("employee2");
Expression<?> expr = select(employee, employee2.id).from(employee).innerJoin(employee.superiorIdKey, employee2);
SQLSerializer serializer = new SQLSerializer(new Configuration(SQLTemplates.DEFAULT));
serializer.handle(expr);
assertEquals("(select EMPLOYEE.ID, EMPLOYEE.FIRSTNAME, EMPLOYEE.LASTNAME, EMPLOYEE.SALARY, EMPLOYEE.DATEFIELD, EMPLOYEE.TIMEFIELD, EMPLOYEE.SUPERIOR_ID, employee2.ID as col__ID7\n" + "from EMPLOYEE EMPLOYEE\n" + "inner join EMPLOYEE employee2\n" + "on EMPLOYEE.SUPERIOR_ID = employee2.ID)", serializer.toString());
}
use of com.querydsl.sql.domain.QEmployee in project querydsl by querydsl.
the class RelationalPathExtractorTest method joins.
@Test
public void joins() {
QEmployee employee2 = new QEmployee("employee2");
SQLQuery<?> query = query().from(employee).innerJoin(employee2).on(employee.superiorId.eq(employee2.id));
assertEquals(ImmutableSet.of(employee, employee2), extract(query.getMetadata()));
}
use of com.querydsl.sql.domain.QEmployee in project querydsl by querydsl.
the class SQLSerializerTest method withRecursive.
@SuppressWarnings("unchecked")
@Test
public void withRecursive() {
/*with sub (id, firstname, superior_id) as (
select id, firstname, superior_id from employee where firstname like 'Mike'
union all
select employee.id, employee.firstname, employee.superior_id from sub, employee
where employee.superior_id = sub.id)
select * from sub;*/
QEmployee e = QEmployee.employee;
PathBuilder<Tuple> sub = new PathBuilder<Tuple>(Tuple.class, "sub");
SQLQuery<?> query = new SQLQuery<Void>(SQLTemplates.DEFAULT);
query.withRecursive(sub, unionAll(select(e.id, e.firstname, e.superiorId).from(e).where(e.firstname.eq("Mike")), select(e.id, e.firstname, e.superiorId).from(e, sub).where(e.superiorId.eq(sub.get(e.id))))).from(sub);
QueryMetadata md = query.getMetadata();
md.setProjection(Wildcard.all);
SQLSerializer serializer = new SQLSerializer(Configuration.DEFAULT);
serializer.serialize(md, false);
assertEquals("with recursive sub as ((select EMPLOYEE.ID, EMPLOYEE.FIRSTNAME, EMPLOYEE.SUPERIOR_ID\n" + "from EMPLOYEE EMPLOYEE\n" + "where EMPLOYEE.FIRSTNAME = ?)\n" + "union all\n" + "(select EMPLOYEE.ID, EMPLOYEE.FIRSTNAME, EMPLOYEE.SUPERIOR_ID\n" + "from EMPLOYEE EMPLOYEE, sub\n" + "where EMPLOYEE.SUPERIOR_ID = sub.ID))\n" + "select *\n" + "from sub", serializer.toString());
}
Aggregations