openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dain Sundstrom <>
Subject Re: JPA spec wierdism?
Date Fri, 16 Feb 2007 01:21:00 GMT
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. ;-)


>> 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


View raw message