I have a performance problem getting data from the database. I have a modeltree with some oneToMany relations (see attached image). If I try to read only a specific amount of records with the Query#setMaxResults function, the created sql statements seems the problem.
The first is is correct: SELECT t0.id, t0.name FROM test_head t0 ORDER BY t0.id DESC LIMIT ?
But the following statements, which read the relations, run without any restrictions: SELECT t0.id, t1.id, t1.head_id, t1.text FROM test_head t0 INNER JOIN test_lines t1 ON t0.id = t1.head_id ORDER BY t0.id ASC, t1.id
This select produces two full tablescans on the database.
I added a exampleproject as an attachment.
Made I something wrong or is the a bug in openjpa?