Return-Path: Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: (qmail 55478 invoked from network); 14 Sep 2010 14:57:01 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 14 Sep 2010 14:57:01 -0000 Received: (qmail 5372 invoked by uid 500); 14 Sep 2010 14:57:01 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 5096 invoked by uid 500); 14 Sep 2010 14:56:58 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 5079 invoked by uid 99); 14 Sep 2010 14:56:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Sep 2010 14:56:56 +0000 X-ASF-Spam-Status: No, hits=4.4 required=10.0 tests=FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of curtisr7@gmail.com designates 74.125.83.46 as permitted sender) Received: from [74.125.83.46] (HELO mail-gw0-f46.google.com) (74.125.83.46) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Sep 2010 14:56:52 +0000 Received: by gwj17 with SMTP id 17so2925457gwj.33 for ; Tue, 14 Sep 2010 07:56:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=Is6yTu6nHGWsQa1DbkIVfRGKo0efHi34lNYpf79OSyc=; b=oWquxX8X+RUCHHlgHYjvfBV7K5Ix6GpjvfAZCxh6nO+sDfnozGRDaUsY7s4zRv8OWq kx2XQrcC3tNehChcQhXmwnn/GjDwtn2BBqA9ehmqIRhLQxu15smFc26WQ4LFdaPkYC6/ wfuynIDqNe5/pfkYvy83ZEOYrnarLTIbJlpgU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=wcW/H/GdDF1nno+67ha4OSp64kQags3QU8btrmcq5/Dzg7c00fn6KhQX3dcj6lI97t 7SBEwMyFrtXVWG/gEWYWDETP+eCEjv0Tf9ggXP+WQxOUjKsxvQgi9aThZG/JR5PqYG03 qRbm6luVcnITYeLh5FYW12SamjxRAKpQ5mv7I= MIME-Version: 1.0 Received: by 10.150.49.16 with SMTP id w16mr297733ybw.119.1284476191179; Tue, 14 Sep 2010 07:56:31 -0700 (PDT) Received: by 10.151.103.17 with HTTP; Tue, 14 Sep 2010 07:56:31 -0700 (PDT) In-Reply-To: References: Date: Tue, 14 Sep 2010 09:56:31 -0500 Message-ID: Subject: Re: Defining named queries in xml From: Rick Curtis To: users@openjpa.apache.org Content-Type: multipart/alternative; boundary=000e0cd6aa5819067a0490396b90 --000e0cd6aa5819067a0490396b90 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hakon - > ... it's possible to specify the named queries in a separate file, and still define the entities using annotations? Yes, you can specify mapping information in annotations and via mapping file(s). In the case where mapping information is specified in both annotations and xml, the xml mapping information will always take precedence. For example, if you wanted to use the orm.xml file for only your named queries, you could do something along these lines (borrowed from our unit test bucket)... SELECT xfa FROM XMLFieldAccess2 xfa WHERE xfa.id =3D :id AND xfa.strField =3D :strVal This information can be put in a couple different places. The easiest is to put it in META-INF/orm.xml. Another option is to create another xml file an= d you'll need to specify org/apache/openjpa/persistence/xml/orm.xml in your persistence.xml. If you follow one of these two options correctly, the enhancer will find the mapping file(orm.xml) and instrument your Entities correctly. > Are there any guides on how to work with orm files using openjpa(?) Unfortunately I haven't found much good information, even the spec is prett= y light on mapping using the orm.xml. Maybe someone else on the list has some input? One good place to look for examples is the openjpa unit tests. We have a pretty exhaustive test suite that should help get you going. Thanks, Rick 2010/9/14 H=E5kon Sagehaug > Hi all, > > Up til now I created my entities using the java annotations with queries > etc, but was wondering if it's possible to specify the named queries in a > separate file, and still define the entities using annotations. Or do I > have > to do my entities in orm file if I want the named queries in XML or > similar. > > Are there any guides on how to work with orm files using openjpa, does th= e > enhancer create the needed java classes from the XML or how does it work? > > Cheers, H=E5kon > --000e0cd6aa5819067a0490396b90--