Hi Daryl, This is one feature, for a long time, I am interested to be included in JPA or at least in OpenJPA. Having your queries *only* in the major compilation unit is a poor idea for usability point of view and takes away much of the power from tuning a query a posteriori. However, I had considered the facility slightly differently than yours. The primary feature that I considered important in this aspect is to dissociate my queries from the major compilation units. The compilation units will only refer them by name.
How about the following <property name="openjpa.NamedQueryRegistry" value="path/to/file/that/contains/NamedQueries.java"/> and in code Query q = em.createQuery("ANameThatAppearsInNamedQueryRegsitry"); Daryl Stultz wrote: > > Hello, > > I'm frustrated by the fact that I need to define @NamedQuery and others > inside my entity classes. I would like to put what I consider "logic" > where > I think it's appropriate which is often not with the model. Is there a way > to programmatically define Named Queries Sql Result Set Mappings, etc and > register them with the persistence engine? I.e. is there any alternative > to > using annotations/xml for defining these things? > > String query = "select o..."; > NamedQuery nq = new NamedQuery(query); > Persistence.registerNamedQuery(nq); > > Thanks. > > -- > Daryl Stultz > _____________________________________ > 6 Degrees Software and Consulting, Inc. > http://www.6degrees.com > mailto:da...@6degrees.com > > ----- Pinaki Poddar http://ppoddar.blogspot.com/ http://www.linkedin.com/in/pinakipoddar OpenJPA PMC Member/Committer JPA Expert Group Member -- View this message in context: http://n2.nabble.com/Code-organization-tp3030386p3031038.html Sent from the OpenJPA Users mailing list archive at Nabble.com.