Hi
I'm having a problem converting an sql query to HQL
This is mysql query
Code:
SELECT t.atos_idAtos, t1.dataAto, CONCAT_WS(' ', c.Nome, c.Apelido) AS clienteA, CONCAT_WS(' ', c1.Nome, c1.Apelido) AS clienteB, s.Documento,
t.Pasta, t.Livro, t.Folhas
FROM atos_has_servicos AS t
INNER JOIN atos AS t1 ON(t.atos_idAtos = t1.idAtos)
INNER JOIN contactos AS c ON (t1.idContacto1 = c.idcontactos)
INNER JOIN contactos AS c1 ON (t1.idContactos2 = c1.idcontactos)
INNER JOIN servicos AS s ON (t.Servicos_idServicos = s.idServicos)
WHERE t1.idAtos = :idAtos;
And when i'm try to put this into HQL
Code:
SELECT a.pasta, a.livro, at.dataAto, s.documento FROM AtosHasServicos a JOIN a.atos at JOIN a.servicos s join at.contactos c
i have the following error
Caused by: org.hibernate.QueryException: could not resolve property: contactos of: model.Atos
But Model "Atos" has this property
Code:
@JoinColumn(name = "idContacto1", referencedColumnName = "idcontactos")
@ManyToOne(optional = false)
private Contactos idContacto1;
@JoinColumn(name = "idContactos2", referencedColumnName = "idcontactos")
@ManyToOne(optional = false)
private Contactos idContactos2;
And "Contactos" model
Code:
@OneToMany(cascade = CascadeType.ALL, mappedBy = "idContacto1")
private Set<Atos> atosSet;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "idContactos2")
private Set<Atos> atosSet1;
any help?