How queryDSL works with interface?

我只是一个虾纸丫 提交于 2019-12-11 10:23:07

问题


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{
}

And another class that holds the Employee implementations:

public class Department{
     private ArrayList<Employee> employees;

     public ArrayList<Employee> getEmployees();
}

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?

I suspect the Q class generated is not correct. I got

public final SimplePath<java.util.ArrayList<Employee>>

in the generated Q class. Shouldn't it be ListPath instead of SimplePath?


回答1:


There are two issues here

  • 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

Consider annotating Employee and use List instead of ArrayList



来源:https://stackoverflow.com/questions/20087378/how-querydsl-works-with-interface

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!