use of com.querydsl.sql.domain.QEmployee in project querydsl by querydsl.
the class SubqueriesBase method list_in_query.
@Test
@ExcludeIn({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, SQLITE, SQLSERVER })
public void list_in_query() {
QEmployee employee2 = new QEmployee("employee2");
query().from(employee).where(Expressions.list(employee.id, employee.lastname).in(query().from(employee2).select(employee2.id, employee2.lastname))).select(employee.id).fetch();
}
use of com.querydsl.sql.domain.QEmployee in project querydsl by querydsl.
the class SubqueriesBase method subQuery_rightJoin.
@Test
@ExcludeIn(SQLITE)
public void subQuery_rightJoin() {
SubQueryExpression<Integer> sq = query().from(employee2).select(employee2.id);
QEmployee sqEmp = new QEmployee("sq");
query().from(employee).rightJoin(sq, sqEmp).on(sqEmp.id.eq(employee.id)).select(employee.id).fetch();
}
use of com.querydsl.sql.domain.QEmployee in project querydsl by querydsl.
the class SelectOracleBase method sumOver.
@Test
@IncludeIn(ORACLE)
@SkipForQuoted
public void sumOver() throws SQLException {
// SQL> select deptno,
// 2 ename,
// 3 sal,
// 4 sum(sal) over (partition by deptno
// 5 order by sal,ename) CumDeptTot,
// 6 sum(sal) over (partition by deptno) SalByDept,
// 7 sum(sal) over (order by deptno, sal) CumTot,
// 8 sum(sal) over () TotSal
// 9 from emp
// 10 order by deptno, sal;
expectedQuery = "select e.LASTNAME, e.SALARY, " + "sum(e.SALARY) over (partition by e.SUPERIOR_ID order by e.LASTNAME asc, e.SALARY asc), " + "sum(e.SALARY) over (order by e.SUPERIOR_ID asc, e.SALARY asc), " + "sum(e.SALARY) over () from EMPLOYEE e order by e.SALARY asc, e.SUPERIOR_ID asc";
oracleQuery().from(employee).orderBy(employee.salary.asc(), employee.superiorId.asc()).select(employee.lastname, employee.salary, SQLExpressions.sum(employee.salary).over().partitionBy(employee.superiorId).orderBy(employee.lastname, employee.salary), SQLExpressions.sum(employee.salary).over().orderBy(employee.superiorId, employee.salary), SQLExpressions.sum(employee.salary).over()).fetch();
// shorter version
QEmployee e = employee;
oracleQuery().from(e).orderBy(e.salary.asc(), e.superiorId.asc()).select(e.lastname, e.salary, SQLExpressions.sum(e.salary).over().partitionBy(e.superiorId).orderBy(e.lastname, e.salary), SQLExpressions.sum(e.salary).over().orderBy(e.superiorId, e.salary), SQLExpressions.sum(e.salary).over()).fetch();
}
use of com.querydsl.sql.domain.QEmployee 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());
}
use of com.querydsl.sql.domain.QEmployee in project querydsl by querydsl.
the class SQLSerializerTest method noSchemaInWhere.
@Test
public void noSchemaInWhere() {
Configuration defaultWithPrintSchema = new Configuration(new SQLTemplates(Keywords.DEFAULT, "\"", '\\', false, false));
defaultWithPrintSchema.getTemplates().setPrintSchema(true);
QEmployee e = QEmployee.employee;
SQLDeleteClause delete = new SQLDeleteClause(EasyMock.createNiceMock(Connection.class), defaultWithPrintSchema, e);
delete.where(e.id.gt(100));
assertEquals("delete from PUBLIC.EMPLOYEE\n" + "where EMPLOYEE.ID > ?", delete.toString());
}
Aggregations