我有一个这样的实体模型:
public class Facture implements Serializable
{
@Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQ_FACTURE")
private long idFacture;
...
private Panier panier;
...
}
public class Panier
{
@Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQ_PANIER")
private long idPanier;
@ManyToOne
private Client client;
@OneToMany
private List<LignePanier> articles = new ArrayList<LignePanier>();
...
}
public class Client
{
@Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQ_CLIENT")
private long idClient;
...
}
所以我想从客户端 X 查询所有的事实。我尝试这样的事情:
public List<Facture> listeFacture(Long clientID) {
List<ParameterMap> parameters = new ArrayList<ParameterMap>();
parameters.add(new ParameterMap(StandardBasicTypes.LONG, clientID));
return dao.query("select facture from Facture facture where facture.panier.client.idClient = ?", parameters);
}
我得到这个例外:
org.hibernate.QueryException: could not resolve property: client of: be.infoserv.web.model.Facture [select facture from be.infoserv.web.model.Facture facture where facture.panier.client.idClient = ?]
我认为不可能像这样查询通过对象,但我不知道如何编写这个查询......
对不起我的英语,我是法国用户。