Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 4440 invoked from network); 3 Aug 2007 14:47:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Aug 2007 14:47:30 -0000 Received: (qmail 86699 invoked by uid 500); 3 Aug 2007 14:47:30 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 86539 invoked by uid 500); 3 Aug 2007 14:47:29 -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 86530 invoked by uid 99); 3 Aug 2007 14:47:29 -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 07:47:29 -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 ppoddar@bea.com designates 66.248.192.39 as permitted sender) Received: from [66.248.192.39] (HELO repmmg02.bea.com) (66.248.192.39) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Aug 2007 14:47:25 +0000 Received: from repmmr01.bea.com (repmmr01.bea.com [10.160.29.71]) by repmmg02.bea.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id l73El35n013080 for ; Fri, 3 Aug 2007 07:47:03 -0700 Received: from repbex01.amer.bea.com (repbex01.bea.com [10.160.26.98]) by repmmr01.bea.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id l73El1Xq000654 for ; Fri, 3 Aug 2007 07:47:02 -0700 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: RE: Equivalent class in OpenJPA. Date: Fri, 3 Aug 2007 07:46:52 -0700 Message-ID: <3992B07C0590B548BB294D31768A1DA250BF36@repbex01.amer.bea.com> In-Reply-To: <11983221.post@talk.nabble.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Equivalent class in OpenJPA. Thread-Index: AcfV0VDH56Ooo76sQRW0tNRnUc33yAACk0cQ References: <11983221.post@talk.nabble.com> From: "Pinaki Poddar" To: x-BEA-PMX-Instructions: AV x-BEA-MM: Internal-To-External X-Virus-Checked: Checked by ClamAV on apache.org 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.