从 QueryDSL 中的 Class 对象生成 Q-type

Generate Q-type from Class object in QueryDSL

我有一个方法 returns 我要查询的实体的 Class 对象:

protected abstract Class<T> getEntityClass();

以后我想用 QueryDSL

查询这个实体
new JPAQuery<>(em).from(?????);

我怎样才能做到这一点?

我刚刚发现我可以使用 PathBuilder:

PathBuilder<Person> pathBuilder = new PathBuilder(Person.class, "PERSON");

List<Person> fetch = new JPAQuery<Person>(em)
                .from(pathBuilder)
                .fetch();