我正在使用 EL,当我运行下面的查询时,我一直得到 0。我想获取当前处于活动状态的申请人 (AP) 的数量。子实体申请人是个人,我想避免查询个人的所有元素?
@RooJavaBean
@RooToString
@RooEntity(identifierColumn = "personID", inheritanceType = "SINGLE_TABLE")
@DiscriminatorColumn(name = "TYPE", discriminatorType = DiscriminatorType.STRING, length = 20)
@DiscriminatorValue("P")
public class Person {
@NotNull
@Size(min = 1, max = 50)
private String FirstName;
@NotNull
@Size(min = 1, max = 50)
private String LastName;
}
子实体“申请人”
@RooJavaBean
@RooToString
@RooEntity
@DiscriminatorValue("AP")
public class Applicant extends Person{
private String major;
private String nativeLanguage;
private String ethnicity;
private String hispanic;
}
我的查询尝试:
/**
*
* @return
*/
public int getCountActiveApplicants(){
EntityManager entityManager = factory.createEntityManager();
int value = entityManager.createQuery("select count(distinct o) from Person o where o.TYPE = \"AP\" AND o.active = \"Yes\" ").getFirstResult();
System.out.println("wowzer " + value + "\n");
return value;
}