我正在尝试创建一些别名来建立一个标准来搜索许多子类的属性。这是我的模型:
public abstract class Entity {
protected int id;
protected PartyBasicGroup partyBasicGroup;
}
public class Person extends Entity {
}
public class Organization extends Entity {
protected PartyBasicGroup signatoryBasicGroup;
protected String jobTitle;
}
我正在尝试为 Person 和 Organization 创建一些别名,如下所示:
criteria = criteria.createAlias("entity.person", "person", JoinType.LEFT_OUTER_JOIN);
criteria = criteria.createAlias("entity.organization", "organization", JoinType.LEFT_OUTER_JOIN);
但我收到一个错误:
Couldn't resolve property person for Entity
任何帮助解决这个问题?我只想知道如何创建别名来引用子类以访问子类属性。
谢谢!