Hi all,
how do you feel about Daniel Sachse's proposal on the observer list ?
Having talked to a couple of users I got the feedback that they'd
consider it a quite useful feature.
Precise name of the annotation would have to be discussed. I'd rather
expect standard JPQL syntax for the query string (selects only, of
course) or preferably names of named Queries. In the latter case one
might also dare to think of a load attribute for the @Transient
annotation. Support of fetch types would be helpful.
Comments ?
Best regards
Rainer
------- Weitergeleitete Nachricht / Forwarded message -------
Datum: Thu, 8 Dec 2011 11:06:09 +0100
Von: Daniel Sachse <sachsedaniel_at_googlemail.com>
An: users_at_jpa-spec.java.net
Betreff: [jpa-spec users] Proposal: Introduce @Query
annotation for fields
Antwort an: users_at_jpa-spec.java.net
Hello everyone,
I would like to propose a new feature for JPA. To make it more clear,
I will show you my use case:
I have got a customer object with a list of offers:
<code>
@OneToMany
private List<Order> orders;
</code>
So far, so good. As soon as I want a List with all undelivered
orders,
I have to create a separate business method, call the EntityManager
with a specific query and set the resultset in my POJO.
>From my point of view, this is overhead!
My proposal:
<code>
@Transient
@Query("FROM Order WHERE delivered = false")
private List<Order> undeliveredOrders;
</code>
But I don't want it only to apply for collections, but also for other
field types:
<code>
@Transient
@Query("FROM Order WHERE status = ? ORDER BY ", OrderStatus.Failed)
private Order lastFailedOrder;
</code>
Additionally a FetchType would be good to specify.
Regards,
Daniel
--- Ende der weitergeleiteten Nachricht / End of forwarded message ---
---
Rainer Schweigkoffer SAP AG Walldorf
Business Solution & Technology TD Core JI
Technology Development Dietmar-Hopp-Allee 16
Java Server Core D-69190 Walldorf
JEE Implementation Group phone: +49 6227 7 45305
Building 3, I.3.14 fax: +49 6227 7 821177
rainer.schweigkoffer_at_sap.com
Sitz der Gesellschaft/Registered Office: Walldorf, Germany
Vorstand/SAP Executive Board: Werner Brandt, Bill McDermott (Co-CEO),
Gerhard Oswald, Vishal Sikka, Jim Hagemann Snabe (Co-CEO)
Vorsitzender des Aufsichtsrats/Chairperson of the SAP Supervisory
Board: Hasso Plattner
Registergericht/Commercial Register Mannheim No HRB 350269
Diese E-Mail kann Betriebs- oder Geschaeftsgeheimnisse oder sonstige
vertrauliche Informationen enthalten. Sollten Sie diese E-Mail
irrtuemlich erhalten haben, ist Ihnen eine Verwertung des Inhalts,
eine Vervielfaeltigung oder Weitergabe der E-Mail ausdruecklich
untersagt. Bitte benachrichtigen Sie uns und vernichten Sie die
empfangene E-Mail. Vielen Dank.
This e-mail may contain trade secrets or privileged, undisclosed, or
otherwise confidential information. If you have received this e-mail
in
error, you are hereby notified that any review, copying, or
distribution
of it is strictly prohibited. Please inform us immediately and
destroy the
original transmittal. Thank you for your cooperation.