using EntityManager to return a List

0

Well, I'm having a problem when I get a list of phones from the bank, these phones have to belong to a CPF.

In my query I do this

public List<Telefone> buscar(Proprietario proprietario) {
      return this.manager.createQuery("select e from Telefone e where 
       e.cpfProprietario = :cpfProprietario").setParameter("cpfProprietario", proprietario.getCpfProprietario()).getResultList();
}

Where am I going wrong?

The Telephone entity has a relationship with an owner.

If you need more information, feel free to contact us at github

p>     
asked by anonymous 19.05.2017 / 03:56

1 answer

0

With JPQL the Query are made OO style, its error and put e.cpfProprietario being that the Phone class does not have a property called cpfProprietario but rather an owner that contains cpfProprietario. What might be confusing you and that the phone table has a cpfOwner column.

public List<Telefone> buscar(Proprietario proprietario) {
      return this.manager.createQuery("select e from Telefone e where 
       e.proprietario.cpfProprietario = :cpfProprietario").setParameter("cpfProprietario", proprietario.getCpfProprietario()).getResultList();
}
    
19.05.2017 / 16:55