I have a entity model like this:
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;
...
}
So I would like to query all the facture from a client X. I try something like this:
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);
}
I get this exception:
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 = ?]
I think it's not possible to query throuth object like this but i don't know how to write this query...
Sorry for my english, i am a french user.