jsr338-experts@jpa-spec.java.net

[jsr338-experts] Re: named queries

From: Evan Ireland <eireland_at_sybase.com>
Date: Thu, 14 Apr 2011 08:18:02 +1200

Inside a Java EE server, we need to capture the "EMF creation" moment
andf allow code injection then to allow this feature to be useful.

(Unless it is limited to Java standalone environments).

> -----Original Message-----
> From: Linda DeMichiel [mailto:linda.demichiel_at_oracle.com]
> Sent: Thursday, 14 April 2011 6:40 a.m.
> To: kwesi_at_sap.com
> Cc: jsr338-experts_at_jpa-spec.java.net
> Subject: [jsr338-experts] Re: named queries
>
> Hi Rainer,
>
> On 4/13/2011 1:09 AM, Rainer Kwesi Schweigkoffer wrote:
> > Hi Linda,
> >
> > what is the precise use case we want to address with this feature ?
> >
>
> Currently dynamically created queries are only scoped to the
> lifecycle of the EntityManager under which they were created.
> Developers would like to be able to create named queries at
> application startup/ EMF creation time that are scoped to
> the persistence unit rather than just to the entity manager.
>
> > 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 ?
> >
>
> No, that was not the intent.
>
> best regards,
>
> -Linda
>
> > 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.
> >
> >
>