Return person and phone list

0

I have an entity called Pessoa . This entity has a list of phones of the Telefone entity.

How do I get the person's information and popular that person's phone list in select with only hql ?

When using the query select u FROM Pessoa , a lot of data is returned. I would like to optimize and bring only the fields código , nome and the phone list.

The expected result would be equal to this:

Thanks for the attention

    
asked by anonymous 26.04.2017 / 19:10

1 answer

0

Have you mapped the relationship of the Person and Phone entities?

If they are mapped with eager Hibernate will do it for you. Through hql you will need to use the join.

Something like:

Select u FROM Pessoa u join Telefone t where u.idPessoa = t.idPessoa
    
26.04.2017 / 22:41