Skip to main content

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

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




Back to the top