Note that there are some explanatory texts on larger screens.

plurals
  1. POAvoiding N+One selects and Invalid results from eclipselink with batch read
    primarykey
    data
    text
    <p>I'm trying to cut down the number of n+1 selects incurred by my application, the application uses EclipseLink as an ORM and in as many places as possible I've tried to add the batch read hint to queries. In a large number of places in the app I don't always know exactly what relationships I'll be traversing (My view displays fields based on user preferences). At that point I'd like to run one query to populate all of those relationships for my objects. </p> <p>My dream is to call something like ReadAllRelationshipsQuery(Collection,RelationshipName) and populate all of these items so that later calls to:</p> <p>Collection.get(0).getMyStuff will already be populated and not cause a db query. How can I accomplish this? I'm willing to write any code I need to but I can't find a way that work with the eclipselink framework?</p> <blockquote> <p>Why don't I just batch read all of the possible fields and let them load lazily? What I've found is that the batch value holders that implement batch reads don't behave well with the eclipselink cache. If a batch read value holder isn't "evaluated" and ends up in the eclipse link cache it can become stale and return incorrect data (This behavior was logged as an eclipselink bug but rejected...) <strong>edit</strong>: I found the link to the bug here: <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=326197" rel="noreferrer">https://bugs.eclipse.org/bugs/show_bug.cgi?id=326197</a></p> </blockquote> <p>How do I avoid N+1 selects for objects I already have a reference to?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload