Hello everyone,
I have an EclipseLink 1.0.1 mapped class A that has mapped
relationships to a number of other classes. I wish to reduce the number of
queries being executed by using EclipseLink Batch Reading across some of those
relationships. Lets say those relationships are to classes of type B, C, D, and
E. Those relationship types are one OneToOne, two OneToManys, and one
ManyToMany. I have a named query that appears to handle the batching of classes
of type E, but when I expand the query hints to include classes B, C, and D, it
does not appear that all instances of B are attempted to be read in one SQL
statement, same for the instances of C and D. I start with an annotation based
named query of the following form:
@NamedQuery(name="A.findForContext",
query = "SELECT a FROM A a WHERE a.id=:aId",
hints={@QueryHint(name=CACHE_USAGE, value=DoNotCheckCache),
@QueryHint(name=REFRESH_CASCADE, value=CascadeByMapping),
@QueryHint(name=QueryHints.REFRESH, value=TRUE),
@QueryHint(name=BATCH, value="a.es")})
And EclipseLink
honors that batch reading hint by executing one query to hydrate all of the E
instances given a set of A instances already hydrated. Now, if I expand the
query hints as described below to request that B, C, and D instances also be
batch read, I see one query for each B, C, and D instance for a given A instance,
not what I am hoping for.
@NamedQuery(name="A.findForContext",
query = "SELECT a FROM A a WHERE a.id=:aId",
hints={@QueryHint(name=CACHE_USAGE, value=DoNotCheckCache),
@QueryHint(name=REFRESH_CASCADE, value=CascadeByMapping),
@QueryHint(name=QueryHints.REFRESH, value=TRUE),
@QueryHint(name=BATCH, value=”a.bs”),
@QueryHint(name=BATCH, value=”a.cs”),
@QueryHint(name=BATCH, value=”a.ds”),
@QueryHint(name=BATCH, value="a.es")})
Anyone
have any ideas of why my batch based query hints would be ignored? I do not
have any JoinFetch relationships in the mix here.
Thanks,
Doug