I use this query on mysql (every record within tbl1 has a list of records within tbl2):
select tbl1.id, tbl2.id from parenttable1 tbl1 join childtable2 tbl2 on tbl1.id = tbl2.tbl1Id
and the result is true but when I use this as a Native Query (javax.persistence.EntityManager#createNativeQuery()) within my application the tbl2.id is repeated. what is the problem?
the result is something like this:
id id
11 1
11 1
22 3
33 4
44 5
44 5
44 5
but i expect:
id id
11 1
11 2
22 3
33 4
44 5
44 6
44 7
my code is something like this:
List<MyDTO> foundList = (List<MyDTO>) entityManager.createNativeQuery("the query above",
MyDTO.class).getResultList();