Today we load the objects once using a Criteria query . And and to return the object by relevance, we call {{ ObjectLoaderHelper.returnAlreadyLoadedObjectsInCorrectOrder }} which in the {{ @DocumentId != @Id }} case, runs one criteria query per object again. That leads to 1+n queries which is not acceptable.
To work around that we could (only in the {{ @DocumentId != @Id }} ) case: - * run the first criteria query so that it returns a List of tuples { documentIdProperty, entity } - * keep this List around - * when loading entities ber per relevant order, use this list to fetch the data from memory instead of this additional n Criteria queries)
|