jsr338-experts@jpa-spec.java.net

[jsr338-experts] Re: named queries

From: Rainer Kwesi Schweigkoffer <kwesi_at_sap.com>
Date: Wed, 13 Apr 2011 10:09:52 +0200

Hi Linda,

what is the precise use case we want to address with this feature ?

Do we want to just enable later reuse of a query, which could already
be done right now by retaining the Query object after execution, and
which could be made more easy by adding a reset method to the Query
interface that cleans up all parameter bindings and/or a clone method
that creates a copy of the query without the parameter bindings ?

Or do we head for inter-thread communication as indicated by Evan ?

Best regards
Rainer

Linda DeMichiel, am 12 Apr 2011 hast Du um 11:43 zum Thema "[jsr338-experts] named queries" geschrieben :

> We've received suggestions to the effect that it would be useful if
> queries could be created dynamically (e.g., at initialization time)
> and then be assigned names so that they could be used for execution
> later.
>
> These queries would have the same scope as other named queries,
> and be associated with the persistence unit.
>
> For example:
>
> TypedQuery<Integer> tq = em.createQuery("SELECT e.seniority FROM Employee e WHERE e.seniority > 10", Integer.class);
> emf.addNamedQuery("Employee_Seniority", tq);
>
> Any configuration of the query object (except for actual parameter
> binding) specified when the query was added as a named query would be
> retained as part of the named query. [I.e., this would include
> configuration information like setMaxResults, setHint, setFlushMode,
> setLockMode, result set mapping information, and information
> registered about stored procedure parameters...]
>
> When the query is executed, information that is settable by means
> of the Query API can be overridden. Information that is overridden
> does not affect the named query as registered with the EMF, and
> thus does not affect subsequent Query objects created by means
> of the name via the EntityManager createNamedQuery method.
>
>
> Linda
>


---
Rainer Schweigkoffer                      SAP AG Walldorf
Business Solution & Technology            TD Core JS&I
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, Angelika Dammann,
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.