From open-jpa-dev-return-2226-apmail-incubator-open-jpa-dev-archive=incubator.apache.org@incubator.apache.org Fri Feb 16 01:21:47 2007 Return-Path: Delivered-To: apmail-incubator-open-jpa-dev-archive@locus.apache.org Received: (qmail 71188 invoked from network); 16 Feb 2007 01:21:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Feb 2007 01:21:47 -0000 Received: (qmail 45787 invoked by uid 500); 16 Feb 2007 01:21:54 -0000 Delivered-To: apmail-incubator-open-jpa-dev-archive@incubator.apache.org Received: (qmail 45676 invoked by uid 500); 16 Feb 2007 01:21:54 -0000 Mailing-List: contact open-jpa-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: open-jpa-dev@incubator.apache.org Delivered-To: mailing list open-jpa-dev@incubator.apache.org Received: (qmail 45667 invoked by uid 99); 16 Feb 2007 01:21:54 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Feb 2007 17:21:54 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [208.97.132.81] (HELO spaceymail-a1.g.dreamhost.com) (208.97.132.81) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Feb 2007 17:21:43 -0800 Received: from [192.168.15.102] (cpe-76-167-174-30.socal.res.rr.com [76.167.174.30]) by spaceymail-a1.g.dreamhost.com (Postfix) with ESMTP id 3428A195025 for ; Thu, 15 Feb 2007 17:21:22 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v752.3) In-Reply-To: <2D2475B7-DC03-4786-BA60-B391DED431F0@SUN.com> References: <8617DDFA-40F1-4262-9EB9-BA42F46C6040@iq80.com> <2D2475B7-DC03-4786-BA60-B391DED431F0@SUN.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <1D48D8D8-634E-4145-BF03-0326459B3EA2@iq80.com> Content-Transfer-Encoding: 7bit From: Dain Sundstrom Subject: Re: JPA spec wierdism? Date: Thu, 15 Feb 2007 17:21:00 -0800 To: open-jpa-dev@incubator.apache.org X-Mailer: Apple Mail (2.752.3) X-Virus-Checked: Checked by ClamAV on apache.org On Feb 15, 2007, at 5:02 PM, Craig L Russell wrote: > Hi Dain, > > On Feb 15, 2007, at 4:57 PM, Dain Sundstrom wrote: > >> This is the only group of JPA developers, I know of so I'm going >> to ask here... > > This was discussed at length in the expert group and the result is > in the specification. That's too bad. It was a very surprising discovery for me. >> One thing I find strange is the namespace of NamedQueries. I >> declare NamedQueries using either an annotation on my entity or in >> xml using a named-query element nested in my entity element. This >> implies to me as a developer that the named queries are "owned" by >> the entity. > > And yet, they are not. The namespace for queries is the entire > PersistenceUnit. > >> But when you go to use a named query you must retrieve it using >> the EntityManager like this: >> >> Query query = entityManager.createNamedQuery(name); >> >> Which means that the queries have a single global namespace. To >> make matters worse there doesn't seem to be any enforcement in the >> schema to make duplicate queries illegal. > > This allows implementations to add value. ;-) LOL >> Is my understanding correct? > > Yes. The best we could do is to make a recommendation that users > guarantee uniqueness of names by prepending the entity name to the > query name. As a side benefit, it's then possible to actually find > the query to debug it. That is how, I'm declaring my queries now :( >> Also, OpenJPA seems to be ok with duplicate query names and >> randomly pick which one to execute. I think we should at least >> print a warning if a user has duplicate named queries, or maybe >> fire an exception for duplicate names. > > Sounds like added value to me. Care to file a JIRA with your > observations and a request for your preferred implementation? Done. OPENJPA-152 -dain