On Mon, Jun 8, 2009 at 9:36 AM, Daryl Stultz <da...@6degrees.com> wrote:
> On Fri, Jun 5, 2009 at 5:47 PM, Michael Dick <michael.d.d...@gmail.com > >wrote: > > > I think the query isn't compiled until the first time you use it and then > > it's cached by its string form. Might have to look at that code again to > > verify though. > > ... > > > I don't think there's a significant performance difference between the > two > > (if the annotation worked). The annotations might be more expressive > > though.. > > > I'm a bit confused. Are named queries a feature that exists solely for the > purpose of reuse or is there a performance advantage? > There's no performance advantage to @NamedQueries. NamedQueries will perform identical to a static JPQL string - first time it's used we'll compile and cache the generated SQL, optionally cache the results, etc. The documentation on the query SQL cache [1] might be of interest though. [1] http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_cache_querysql NamedQueries are more readable than a static JPQL string but you shouldn't choose them to improve performance. Regards, -mike > > -- > Daryl Stultz > _____________________________________ > 6 Degrees Software and Consulting, Inc. > http://www.6degrees.com > mailto:da...@6degrees.com >