因為時間有限先記錄一下簡單的幾個寫法,今天在項目中嘗試一下,后續補充。
需要了解更多詳細信息可以到官網查看:http://www.querydsl.com/static/querydsl/3.4.3/reference/html_single/#d0e593
主要疑惑的是子查詢先記錄一下:
example:
QDepartment department = QDepartment.department;
QDepartment d = new QDepartment("d"); query.from(department) .where(department.employees.size().eq( new JPASubQuery().from(d).unique(d.employees.size().max()) )).list(department);
QEmployee employee = QEmployee.employee;
QEmployee e = new QEmployee("e"); query.from(employee) .where(employee.weeklyhours.gt( new JPASubQuery().from(employee.department.employees, e) .where(e.manager.eq(employee.manager)) .unique(e.weeklyhours.avg()) )).list(employee);