I have a number of hibernate queries used in a service layer which I would like to externalize into named queries in the mapping xml, and refactor the usages to the form:
Query q = getNamedQuery(String query);
I use XDoclet to generate all the mappings, using a single mapping doc per class.
My questions are:
1) Given that the mappings are all XDoclet-generated, is my only option to provide merge docs for the <query/> elements I want to include into my mappings?
2) What is a common practice of locating the named queries? I find that some of the queries I want to externalize don't neatly fit into a particular persistent class' mapping; they involve several classes, and it seems awkward to stuff them into any given one. Is there a tip to de-couple the named query xml from a particular mapping file?
It would be useful to independently organize a collection of related named queries together, and use a configurations for different applications that include those queries along with the mappings they rely on.
|