本文介绍了queryDSL如何与接口一起工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一组实现相同接口的类.例如:
I have a set of classes that implements the same interface. For example:
public interface Employee{ private String name; public void work(); public String getName(); } @PersistenceCapable(detachable = "true") public class Accountant implements Employee{ } @PersistenceCapable(detachable = "true") public class Secretary implements Employee{ }另一个包含Employee实现的类:
And another class that holds the Employee implementations:
public class Department{ private ArrayList<Employee> employees; public ArrayList<Employee> getEmployees(); }我想获取一个名为"Mary"的雇员的部门列表.我应该如何放置我的jdo查询?我是否在Employee界面上缺少注释?
I want to get a list of Department that has Employee named "Mary". How should I put my jdo query? Am I missing some annotation to the interface Employee?
我怀疑生成的Q类不正确.我有
I suspect the Q class generated is not correct. I got
public final SimplePath<java.util.ArrayList<Employee>>在生成的Q类中的
.是不是ListPath而不是SimplePath?
in the generated Q class. Shouldn't it be ListPath instead of SimplePath?
推荐答案这里有两个问题
- Employee未被识别为实体类型,因为它没有被注释 Querydsl中不支持
- ArrayList的列表类型,仅支持Collection接口
- Employee is not recognized as an entity type, since it is not annotated
- ArrayList is not a supported List type in Querydsl, only Collection interfaces are supported
考虑注释Employee并使用List代替ArrayList
更多推荐
queryDSL如何与接口一起工作?
发布评论