1、嵌套子查询
例如实现sql: select u.* from user where u.id in (select s.id from student s where s.status = 0)
var query = from(user )
.where(user.id.`in`(JPAExpressions
.select(student.id)
.from(student)
.where(student.status = 0))
2、按照日期进行模糊查询
按照日期的月日查询
例如 2018-03-05在2020-03-01和2020-03-31之间
val dateFormat = SimpleDateFormat("MM-dd")
val dateExpr = Expressions.stringTemplate("DATE_FORMAT({0},'%m-%d')", QUser.user.birthDay)
val today = dateFormat.format(Date())
val predicate = QUser.user.status.eq(UserStatus.VALID)
.and(dateExpr.gt("03-01")).and(dateExpr.le(today))