views:

101

answers:

2

For the statistics part of an application there are several queries that often change and are also rather long. Both IMHO arguments to remove the queries from the source code and put them somewhere where they can be easily edited in an eye friendly format and also copy / pasted from and to a QL editor. This disqualifies named-queries from JPA.

The environment is a Seam application, but this question might be interesting for J2EE in general.

From my view there are three solutions: For relative static queries I can use a Seam managed query home, but it handling of parametrized queries is getting ugly when your parameters are not in any scope and just passed as method parameters.

My current solution is to put all queries into a Seam messages file and access them through the messages array.

A third way would be to create your own Seam component that reads the queries from somewhere and provides them.

How do you managed such a scenario? Did I miss some obvious solution?

A: 

You can put queries in components.xml

01
Thanks for response, that was the first approach I described, as mentioned, IMHO it has the drawbacks of unscoped parametrization (or lack thereof).
Elmar Weber
You could also use groovy and its multiline strings(you can make groovy seam components). In this case every solution has its drawbacks.
01
I have been putting my queries in components.xml. I separate my components up by project so if I use a query only in a particular project at a certain layer, I declare it there. There is a JIRA issue filed to externalize them outside of XML, possibly in the entity class, service class, or other specific location that it is used. It would be very similar to @NamedQuery(name = "", query = "") ... type syntax.
A: 

Today appeared similar but not Seam specyfic question in SO, maybe there you'll find some ideas.

cetnar