Jira issue originally created by user @asm89:
When ordering a JTI entity on id, the generated SQL will use the table of the root entity. This is because the root entity is listed as owner of the field in the _owningTableMap, leading to non-optimal queries.
More information see:
Comment created by @asm89:
I can pick this up if it's agreed upon that this could indeed be improved.
Comment created by @ocramius:
The problem here is that joining with a JTI causes LEFT JOINS, which don't perform very well when it comes to sorting the results.
Just as a quick reference, here's where "something" should be changed to get this working:
When the field is part of the primary key, the field used for sorting results should be the one of the table of the entity itself, and not of the root of the CTI.