we are trying to use the QueryRedirector feature of EclipseLink to
realize partially loaded entities. Imagine we have an entity type A
which has a OneToMany relation to a type B. Now we want to load A so
that only those dependend B are loaded that match a certain criteria.
There are two problems involved in this:
a) QueryRedirectors do not work if we use the JPA EntityManager.find()
method, though the JavaDoc for the QueryRedirectors state that a
ReadObject redirector should be invoked.
We assume this is a bug. EntityManagerImpl.findInternal() does not
set a redirector on the created query. Probably this has been
forgotten as the JavaDoc clearly states that it should set the
redirector.
b) We also configured redirectors on the type B expecting that when
EclipseLink loads the B entites related to A, a readAll redirector
should be invoked. This however is not the case, so that we cannot
intercept and modify the query loading of the related B entities.
Do we misunderstand the concept of redirectors here? Shouldn't they
also be able to intercept the loading of related entities? May this
also be a bug?
If you migrate to EclipseLink 1.0.1 you will be able to set a default
redirector on the Entity that will be invoked for all queries on that
Entity. Look at @QueryRedirectors annotation.
--Gordon
as a matter of fact we are using EclipseLink 1.0.1. As far as we can
tell after stepping through the code, what the @QueryRedirectors
annotation documentation tells us is not what is acutally happening.
Richard
Gordon Yorke schrieb:
> If you migrate to EclipseLink 1.0.1 you will be able to set a default
> redirector on the Entity that will be invoked for all queries on that
> Entity. Look at @QueryRedirectors annotation.
> --Gordon
>
Richard,
I am unable to reproduce your problems with the redirectors. I have
default redirectors configured and queries are being redirected to these
classes. EntityManager.find() is being redirected as are mapping queries.
With the EntityManager.find() is it possible you are getting a cache hit
and no query is being executed?