Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support bulk-fetch for 1-N/M-N on not just candidate, but also next level #170

Open
andyjefferson opened this issue Mar 2, 2017 · 0 comments

Comments

@andyjefferson
Copy link
Member

andyjefferson commented Mar 2, 2017

See also datanucleus/datanucleus-core#189.

In JPA when a FETCH JOIN is specified on a 1-N candidate relation then we use bulk-fetch. In this case in question it is FETCH JOIN via 1-1, then FETCH JOIN via 1-N. The latter is not being retrieved, and hence not detached.

In JDO the same applies where we have a candidate with a 1-N, and an element that has a 1-N with something else.

In terms of an example if we have class A with a Collection<B>, and class B with a Collection<C> and we want to bulk fetch the bs and cs when fetching an A, we get

SELECT 'mydomain.model.A' AS DN_TYPE,A0.ID,A0."NAME" FROM A A0

SELECT 'mydomain.model.B' AS DN_TYPE,A1.ID,A1."NAME",A0.ID_OID,A0.IDX AS NUCORDER0 
FROM A_BS A0 INNER JOIN B A1 ON A0.ID_EID = A1.ID 
WHERE A0.IDX >= 0 
AND EXISTS (
    SELECT 'mydomain.model.A' AS DN_TYPE,A0_SUB.ID AS DN_APPID 
    FROM A A0_SUB WHERE A0.ID_OID = A0_SUB.ID
) ORDER BY NUCORDER0

The "problem" in implementing this is that we then need to either expand the second SQL to also add an EXISTS clause on the b.cs field (i.e quite complicated), or do a simple load all Cs for a set of owner Bs.

@andyjefferson andyjefferson changed the title Support bulk-fetch on not just candidate, but also next level Support bulk-fetch for 1-N/M-N on not just candidate, but also next level Feb 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant