Person
| ID | Name |
|---|---|
| 1 | Luis |
| 2 | Frank |
Address
| Person-ID | Address | City |
|---|---|---|
| 1 | Samantha Road | x |
| 1 | Franklin | y |
In my Hibernate native query I want to map the result of one person to a set of addresses, such like the query below.
SELECT ID, LISTAGG(Address, ','), LISTAGG(City, ',')
FROM PERSON
JOIN Address ON ID = Person-ID
WHERE ID= 1
GROUP BY ID
I am not sure how to implement the SqlResultSetMapping
@SqlResultSetMapping(name = "Result",
entities = { @EntityResult(entityClass = Person.class,
fields = { @FieldResult(name = "id", column = "ID"),
{adresses but how...} }) })
public class Result{
@Id
int rowNumber;
private List<Address> adresses;
}