我有3个与@OneToMany关系的链接类
Luce.class
public class Luce implements java.io.Serializable{
private Client client;
}
Client.class
public class Client implements java.io.Serializable{
private Server server;
}
Server.class
public class Server implements java.io.Serializable{
private Piano Piano;
}
我需要从指定的钢琴中获取Luce列表。 因此,在我的DAO接口的实现中,我试图执行以下操作:
Criteria criteria = createEntityCriteria();
criteria.createAlias("client", "c");
criteria.createAlias("server", "s");
criteria.add(Restrictions.eq("c.s.piano", piano);
但是我得到了例外
org.hibernate.QueryException: could not resolve property: server of: it.besmart.models.Luce
答案 0 :(得分:1)
You try to create an alias of the property server on Luce so it won't work.
Criteria criteria = createEntityCriteria();
criteria.createAlias("client", "c");
criteria.createAlias("c.server", "s");
criteria.add(Restrictions.eq("s.piano", piano);