我有一个像这样的持久性模型:
@Entity
public abstract class Employee {
@Id
protected Integer employeeId;
...
}
@Entity
public class FullTimeEmployee extends Employee {
protected Integer salary;
...
}
@Entity
public class PartTimeEmployee extends Employee {
protected Float hourlyWage;
}
我想查询具有某些子类条件的员工,例如:薪水> 1000。
我试过这个但没有工作。
SELECT e
FROM Employee e
WHERE e.salary > 1000;
SELECT e
FROM Employee e
WHERE (TYPE(e) = FullTimeEmployee AND e.salary > 1000)
OR TYPE(e) = PartTimeEmployee;
我还尝试在 Employee 中放置一个抽象方法并在查询中使用它,但也不起作用。
请问你能帮帮我吗 ?
谢谢,