更新时间:2023-08-28 17:07:46
不要将生成的 Q 类型用于动态表达式创建.您可以使用动态路径代替 http://www.querydsl.com/static/querydsl/2.9.0/reference/html/ch03.html#d0e1379
Don't use the generated Q-types for dynamic Expression creation. You can use dynamic paths instead http://www.querydsl.com/static/querydsl/2.9.0/reference/html/ch03.html#d0e1379
在你的情况下是这样的
Class<?> entityType = Class.forName(...)
PathBuilder entityPath = new PathBuilder(entityType, "entity");
PathBuilder relation = entityPath.get("relation");
Predicate predicate = relation.get...(...).eq(...)
对于路径提取使用这个类 http://www.querydsl.com/static/querydsl/2.9.0/apidocs/com/mysema/query/types/PathExtractor.html
For Path extraction use this class http://www.querydsl.com/static/querydsl/2.9.0/apidocs/com/mysema/query/types/PathExtractor.html
PathExtactor
从给定的 Expression