openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Beer <david.m.b...@googlemail.com>
Subject Re: Code organization
Date Fri, 05 Jun 2009 20:25:57 GMT
Hi All

I too would much rather see @NamedQuery(ies) defined in a seperate
class like I do other more complicated queries. I also see this as a
good way of keeping things modular or decoupled from the model.

Using a seperate java class which then registers those queries at run
time would be a good way of doing things. The registration not need be
in the persistence.xml file as long as it can be added to the
persistence unit later.

David

On Fri, 5 Jun 2009 08:33:19 -0700 (PDT)
Pinaki Poddar <ppoddar@apache.org> wrote:

> 
> 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:daryl@6degrees.com
> > 
> > 
> 
> 
> -----
> Pinaki Poddar                      http://ppoddar.blogspot.com/
>                                       
> http://www.linkedin.com/in/pinakipoddar
> OpenJPA PMC Member/Committer
> JPA Expert Group Member


Mime
View raw message