Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top