Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 44475 invoked from network); 3 Aug 2007 15:17:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Aug 2007 15:17:52 -0000 Received: (qmail 42835 invoked by uid 500); 3 Aug 2007 15:17:51 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 42795 invoked by uid 500); 3 Aug 2007 15:17:51 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 42786 invoked by uid 99); 3 Aug 2007 15:17:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Aug 2007 08:17:51 -0700 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of plinskey@gmail.com designates 64.233.166.177 as permitted sender) Received: from [64.233.166.177] (HELO py-out-1112.google.com) (64.233.166.177) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Aug 2007 15:17:47 +0000 Received: by py-out-1112.google.com with SMTP id f31so1454340pyh for ; Fri, 03 Aug 2007 08:17:26 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=FpA3+teVzZPX6tPaG9fjE4d0t7LhzXa2JKZ7M+uDswTFj92uv57pXFn63hNFDaI69dTb7FpxWTOm//4UnDmqr/W15OhECD0p5HG3VKMDtyOgWGrCtlmYgFiQyPE0Hm+4gco6DFq3XHIMLMoEyLGi567y9r04werqeXnFLbRaP64= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=sUjAAbhLRQ1jbwUYUflFfR7T33me3+EvigL9BVrtU3NtwrnB3dSrGXzSworXEyPVJgbbb3rUT3OuGAXN66tw6WLI3udZH9rOMMqmSrQ/aTuRgC6fFosvG30aGk4Djq1B3T1O5/R7ddKTXX7ZQZraiFDWWdA/nHdF3FhH2lSPPms= Received: by 10.35.21.9 with SMTP id y9mr4943715pyi.1186154245923; Fri, 03 Aug 2007 08:17:25 -0700 (PDT) Received: by 10.35.100.9 with HTTP; Fri, 3 Aug 2007 08:17:25 -0700 (PDT) Message-ID: <7262f25e0708030817s498797bfjc3a3ace7805a2b82@mail.gmail.com> Date: Fri, 3 Aug 2007 08:17:25 -0700 From: "Patrick Linskey" To: dev@openjpa.apache.org Subject: Re: Equivalent class in OpenJPA. In-Reply-To: <3992B07C0590B548BB294D31768A1DA250BF36@repbex01.amer.bea.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <11983221.post@talk.nabble.com> <3992B07C0590B548BB294D31768A1DA250BF36@repbex01.amer.bea.com> X-Virus-Checked: Checked by ClamAV on apache.org Also, it'd be good to know more about where the cost is being incurred. In particular, how fast are the query parses after the first run? -Patrick On 8/3/07, Pinaki Poddar wrote: > 1. > Try using named/positional parameters in JPQL. > > Query query = session.createQuery("select model from GeneralConfigDTO > model where model.name = ?cname"); > query.setParameter("cname", configName); > > or > > Query query = session.createQuery("select model from GeneralConfigDTO > model where model.name = :1"); // index starts from 1 > query.setParameter(1, configName); > > If the query being executed multiple times, binding parameters will > save repeated query compilation. > > 2. It may be useful to post the exact SQL being used by Hibernate & > OpenJPA. > > > Pinaki Poddar > 972.834.2865 > > -----Original Message----- > From: Sreedhar.sirigiri [mailto:sreedhar.sirigiri@gmail.com] > Sent: Friday, August 03, 2007 8:22 AM > To: dev@openjpa.apache.org > Subject: Equivalent class in OpenJPA. > > > Hi All, > > We are porting our application from Hibernate to OpenJPA in the Database > tier. We faced performance problems while processing the JPQL queries. > > here are the sample code snippets: > > Hibernate: > > //do something > > Criteria criteria = session.createCriteria(GeneralConfigDTO.class); > criteria.add(Expression.eq("name", configName)); GeneralConfigDTO > configDTO = (GeneralConfigDTO)criteria.uniqueResult(); > > //do something > > OpenJPA: > //do something > > Query query = session.createQuery("select model from GeneralConfigDTO > model where model.name = '"+configName+"'"); try{ > GeneralConfigDTO configDTO = > (GeneralConfigDTO)query.getSingleResult(); > }catch(NoResultException nre){ > configDTO = null; > }catch(NonUniqueResultException ure){ > configDTO = null; > } > > //do something > > We have around 21 tuples in the relation "GeneralConfigDTO". > > The Hibernate code snippet is getting executed in around 20msecs, > whereas, OpenJPA code snippet is taking around 400msecs, which is > accounting for overall performance of the Application. > > The reason why we went for JPQL is because, we didn't find an equivalent > Hibernate's "Criteria" class in OpenJPA. > > Is there any configurations that we have to do to optimize JPQL queries. > > Is there any equivalent class for "Criteria" in OpenJPA. > > Any help would be highly appreciated. > > Thanks in advance. > > Sreedhar Sirigiri. > > > > -- > View this message in context: > http://www.nabble.com/Equivalent-class-in-OpenJPA.-tf4212515.html#a11983 > 221 > Sent from the OpenJPA Developers mailing list archive at Nabble.com. > > > Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it. > -- Patrick Linskey 202 669 5907