Hello Linda,
> What do you think the behavior should be?
Each of the query variants that can be recalled by a name must have a name
that is unique in a persistence unit scope.
Effectively, my answer to the earlier question: "can we define a NamedQuery
and a StoredProedure with the same name?" is "no".
Nor can we define a NamedQuery(name="findAll") in two entity classes A and
B. But spec already prohibits that.
It is a common (or at least good) practice to qualify such common names by
their class scope e.g. "Person.findAll" and
"Order.findAll". So extending the uniqueness across all type of queries
will not be difficult for the developers and will
not invite unnecessary complexity for the providers.
Regards --
Pinaki Poddar
Chair, Apache OpenJPA Project
http://openjpa.apache.org/
JPA Expert Group Member
Application & Integration Middleware
From: Linda DeMichiel <linda.demichiel_at_oracle.com>
To: jsr338-experts_at_jpa-spec.java.net
Date: 05/01/2013 02:51 PM
Subject: [jsr338-experts] Re: Uniqueness of names of
NamedQuery/StoredProcedure
On 5/1/2013 1:09 PM, Pinaki Poddar wrote:
> The spec API uses name as the identifying moniker for named queries and
stored procedures as in
> *public*<T> TypedQuery<T> createNamedQuery(String name, Class<T>
resultClass);
> or
> *public*StoredProcedureQuery createNamedStoredProcedureQuery(String
name);
>
> While the name of a @NamedQuery is scoped within a persistence unit
(Section 3.10.14, pp 150), does this scope also
> include the named stored procedures?
>
> For example, can we define a NamedQuery and a StoredProedure with the
same name?
>
The spec doesn't say so explicitly (although it should), but I would not
expect this to work (or at any
rate be portable).
We'll need to clarify in future.
What do you think the behavior should be?
> Regards --
>
> Pinaki Poddar
> Chair, Apache OpenJPA Project http://openjpa.apache.org/
> JPA Expert Group Member
> Application & Integration Middleware
>
>
>
>