This is the only group of JPA developers, I know of so I'm going to
ask here...
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.
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.
Is my understanding correct?
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.
-dain