On 30 nov. 2011, at 19:42, Linda DeMichiel wrote:
>
> Following up on your points here --
> Is the issue that you want to know if a query of the given name exists:
> a) So you don't clobber it by defining one with the same name?
> b) Because you might want to use it, even though you may not know what it does?
>
> What about adding a replaceIfExists argument to addNamedQuery, which seems a
> simpler approach?
I have a few reasons in mind
- a) is definitely one
- I don't have b) in mind
- I'd like to promote a programming model where metadata and definitions is not mixed or lost within business code and dilute readability
- building the query might be slow or complex and adding it to the pool of named queries will require some synchronization, I'd rather avoid these costs
My view is that we can offer something as nicely isolated than existing named queries but as flexible as programmatically written dynamic queries.
replaceIfExists is solving a) but not the rest.