[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Conditional LEFT JOIN in JPQL
|
1. Constructors are supported through ReportQuery. See
ReportQuery.addConstructorReportItem(ConstructorReportItem item). There should
be nothing different about using these with a query key
2. Parameters are available in your query, but not in the query key you are
using for your ON clause. The issue of Parameters in the ON Clause should be
addressed as part of the solution when bug 312146 is addressed. I suspect that
to fix this issue, we would add explicit "ON" API rather than expanding how
QueryKeys work.
3. Named queries can be added in a SessionCustomizer. See
Session.addQuery(name, databaseQuery). Any query added to the session will be
available through the Named Query API. Here is some information about customizers.
http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#Using_EclipseLink_JPA_Extensions_for_Customization_and_Optimization
http://wiki.eclipse.org/Introduction_to_EclipseLink_Sessions_%28ELUG%29#Session_Customization
http://wiki.eclipse.org/Introduction_to_Descriptors_%28ELUG%29#Descriptor_Customization
-Tom
bht@xxxxxxxxxxxxx wrote:
Hi Tom,
I have a few questions regarding
https://bugs.eclipse.org/bugs/show_bug.cgi?id=312146
1) Can I use a DTO constructor in the EL API query such as in the
attached tescase: select new dto.ProductWithFavoriteDTO(p, f) from
Product left join p.favorites f
2) Can I pass a parameter userId into such a query. If not, is
https://bugs.eclipse.org/bugs/show_bug.cgi?id=312146 addressing this?
I need this behavior because the query is expensive. Please refer to
3).
3) How can I manipulate this query in such a way that it is cached in
EntityManager across sessions, much like a @NamedQuery with
parameters?
Tom, thanks again for your help. I don't want to sound too demanding,
but as a suggestion my questions could be addressed in an easy way by
extending the testcase attached to
https://bugs.eclipse.org/bugs/show_bug.cgi?id=312146
This might be useful for other people too, and it could be posted as
an example (being as simple as it is), and in case of future questions
one could just link to it.
Many thanks,
Bernard
On Tue, 11 May 2010 08:20:05 -0400, you wrote:
Hi Bernard, Vidas,
The best way to get this feature to the top of our implementation list is to
vote for it. One of the main criteria we use when determining which features to
implement next is the number of distinct votes.
I have updated the bug with some information about how to define a query that
retrieves multiple items.
If you want to dynamically define a QueryKey, I believe it should work at the
moment. You will have to use a small amount in internal API. Here is some
pseudo code for the basic steps.
ServerSession session =
(ServerSession)JpaHelper.getServerSession(myEntityManagerFactory)
ClassDescriptor descriptor = session.getDescriptor(MyEntity.class);
descriptor.addQueryKey(myQueryKey);
myQueryKey.initialize(descriptor);
The changes that allow JPQL queries to use query keys will be in our 2.1
release. They appear in our nightly builds starting with last night's build.
-Tom
Vidas Timukas wrote:
Hi, Bernard,
Know nothing about EL API, but, according to Tom's example, might it
be possible to define queryKey on the fly with User.getId() as
ConstantExpression and destroy it after query execution. Maybe Tom can
suggest something about this.
Another question, which rises, how to retrieve both objects in result
list, like List<Product, Favourite>, because ReadAllQuery(Product.class)
from given example seems to return only list of Products.
And last question for Tom: As you said, there is some work to support
queryKeys in JPQL. Can you tell us, in which version of EL it will be
supported:? For example:
SELECT p, f FROM Product p join p.favouritepk f
2010/5/11 <bht@xxxxxxxxxxxxx <mailto:bht@xxxxxxxxxxxxx>>
Hello Vidas,
I created a testcase and Tom responded to it:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=312146
Can you believe that even with the current EclipseLink version, using
the proprietary EclipseLink API, it is not possible to write a query
with a conditional join where the condition comes from a parameter
value?
This is the simplest case I have been able to suggest. So no userId
parameter for the query :(.
It looks like I have to wait for some time (months?, a year?) before
this is implemented, even before the spec is changed.
Would you have any comment? Please vote for this.
Best regards,
Bernard
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx <mailto:eclipselink-users@xxxxxxxxxxx>
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
--
Sincerely,
Vidas
------------------------------------------------------------------------
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users