Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Specify MaxResultSize of "owning" Entity with @QueryHint(LEFT_FETCH...) in NamedQuery + .setMaxResults() ???

Hello Mario,

Joining and batch reading on collection types do not work well when using cursors or other features that limit the results returned. These features work on the database results, not the returned objects to avoid having to bring in large amounts of data. Unfortunately, there is no way to limit database results to a set number of objects on an object bases. There is no way to know without reading in all the rows to tell when a particular object is done being built. If the reason for limiting results is to limit memory use, I would suggest that you not using joining,and instead allow EclipseLink to read in Addresses and Roles with individual queries as it builds each partner. If you are using the cache, some of the partner objects may already exist there, so these queries might not always be necessary.
Best Regards,
Chris

Mario Sandro Schwarz wrote:
Hello everybody,

I have a Partner entity which can have multiple Addresses and multiple Roles. I have a use-case-based query which should retrieve always 50 partners in paging mode.

So I created a NamedQuery, which Selects all Partners and uses two LEFT_FETCH QueryHints to obtain the Adresses and the roles to the partners and limits the result by .setMaxResults. The problem is that the number of results specified by .setMaxResults() refers the whole result set and not just the owning partner entities. And that result set dramatically varies.

Assuming I have 50 Partners, each Partner has 10 addresses and 10 roles. In that case I´d have to set .setMaxResults() to 5000. But what if just the half of the 50 partners have 10 addresses and 10 roles, let´s say the other 25 just have 3.
That would be 25 * 10 * 10 + 25 * 3 * 3 = 2725 rows in the result set.

Any help is appreciated!
Mario


_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top