From open-jpa-dev-return-2311-apmail-incubator-open-jpa-dev-archive=incubator.apache.org@incubator.apache.org Wed Feb 21 23:07:13 2007 Return-Path: Delivered-To: apmail-incubator-open-jpa-dev-archive@locus.apache.org Received: (qmail 47479 invoked from network); 21 Feb 2007 23:07:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Feb 2007 23:07:13 -0000 Received: (qmail 89851 invoked by uid 500); 21 Feb 2007 23:07:21 -0000 Delivered-To: apmail-incubator-open-jpa-dev-archive@incubator.apache.org Received: (qmail 89830 invoked by uid 500); 21 Feb 2007 23:07:21 -0000 Mailing-List: contact open-jpa-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: open-jpa-dev@incubator.apache.org Delivered-To: mailing list open-jpa-dev@incubator.apache.org Received: (qmail 89821 invoked by uid 99); 21 Feb 2007 23:07:21 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Feb 2007 15:07:21 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of plinskey@bea.com designates 66.248.192.22 as permitted sender) Received: from [66.248.192.22] (HELO usremg02.bea.com) (66.248.192.22) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Feb 2007 15:07:10 -0800 Received: from usremr01.bea.com (usremr01.bea.com [10.160.29.91]) by usremg02.bea.com (Switch-3.2.2/Switch-3.2.2) with ESMTP id l1LN6ijm032397 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Wed, 21 Feb 2007 15:06:48 -0800 Received: from repbex02.amer.bea.com (repbex02.bea.com [10.160.26.99]) by usremr01.bea.com (Switch-3.2.2/Switch-3.2.2) with ESMTP id l1LN6gAP023450 for ; Wed, 21 Feb 2007 15:06:42 -0800 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: quoted-printable Subject: RE: svn commit: r510281 - in /incubator/openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ Date: Wed, 21 Feb 2007 15:06:38 -0800 Message-ID: <7D856CDFE035FF45A0420ACBD71BDD63034FD677@repbex02.amer.bea.com> In-Reply-To: <20070221225005.EAECA1A981A@eris.apache.org> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: svn commit: r510281 - in /incubator/openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ Thread-Index: AcdWCrBEJlR3I+6jSeeXiHxy1lghogAATkXw References: <20070221225005.EAECA1A981A@eris.apache.org> From: "Patrick Linskey" To: X-PMX-Version: 4.7.1.128075, Antispam-Engine: 2.5.0.283055, Antispam-Data: 2007.2.21.141434 X-Virus-Checked: Checked by ClamAV on apache.org Some comments: 1. What does "optimize for n" do? Do you have a link where I could read up on it? 2. Is there equivalent magic for other databases? 3. OpenJPA does support a means of passing Oracle hints along through to the DBDictionary. Should we be trying to reuse some of the capabilities here? 4. In the following snippets, I'd rather if we used 'Integer.valueOf(1)' or, better yet, a symbolic constant, instead of creating new integer all the time. > + fetch.setHint("openjpa.hint.optimize", new Integer(1)); > + _query.getFetchConfiguration(). > + setHint("openjpa.hint.optimize", new Integer(1)); 5. I don't like the name 'openjpa.hint.optimize', as it's a bit ambiguous as to what's being optimized. I don't really know what 'optimize for' does, so I'm just guessing here, but how about 'openjpa.ExpectedRecordCount'? 6. How does the user access this from JPQL queries when they don't want to use a getSingleResult() call? Will it work to use the JPA query hint facilities, or do they have to use the broker APIs? Do we even care, since they could just use getSingleResult()? Maybe it's better to not allow this to be user-configurable, if we can always infer the right setting. But I'm guessing that sometimes the user might want to say that they expect 10 results or something like that 7. It seems like this could also be useful for when a one-to-one or a many-to-one is traversed. -Patrick --=20 Patrick Linskey BEA Systems, Inc.=20 _______________________________________________________________________ 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.=20 > -----Original Message----- > From: wisneskid@apache.org [mailto:wisneskid@apache.org]=20 > Sent: Wednesday, February 21, 2007 2:50 PM > To: open-jpa-commits@incubator.apache.org > Subject: svn commit: r510281 - in /incubator/openjpa/trunk:=20 > openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/=20 > openjpa-kernel/src/main/java/org/apache/openjpa/kernel/=20 > openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ >=20 > Author: wisneskid > Date: Wed Feb 21 14:50:04 2007 > New Revision: 510281 >=20 > URL: http://svn.apache.org/viewvc?view=3Drev&rev=3D510281 > Log: > DB2 Optimize for clause enhancement >=20 > Modified: > =20 > incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/ openjpa/jdbc/sql/DB2Dictionary.java > =20 > incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/ openjpa/jdbc/sql/DBDictionary.java > =20 > incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apach e/openjpa/kernel/BrokerImpl.java > =20 > incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/ apache/openjpa/persistence/QueryImpl.java >=20 > Modified:=20 > incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/ openjpa/jdbc/sql/DB2Dictionary.java > URL:=20 > http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-j dbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?> view=3Ddiff&rev=3D510281&r1=3D510280&r2=3D510281 > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > ---=20 > incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/ openjpa/jdbc/sql/DB2Dictionary.java (original) > +++=20 > incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/ openjpa/jdbc/sql/DB2Dictionary.java Wed Feb 21 14:50:04 2007 > @@ -20,6 +20,7 @@ > import java.sql.SQLException; > import java.util.Arrays; > =20 > +import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration; > import org.apache.openjpa.jdbc.schema.Sequence; > =20 > /** > @@ -33,7 +34,7 @@ > validationSQL =3D "SELECT DISTINCT(CURRENT TIMESTAMP) FROM " > + "SYSIBM.SYSTABLES"; > supportsSelectEndIndex =3D true; > - > + optimizeClause =3D"optimize for"; > nextSequenceQuery =3D "VALUES NEXTVAL FOR {0}"; > =20 > sequenceSQL =3D "SELECT SEQSCHEMA AS SEQUENCE_SCHEMA, " > @@ -190,5 +191,21 @@ > } > } > } > + } > + =20 > + public String getOptimizeClause(JDBCFetchConfiguration fetch) { > + Integer rows =3D null; > + StringBuffer optimizeString =3D null; > + if (fetch.getHint("openjpa.hint.optimize") !=3D null) { > + optimizeString =3D new StringBuffer(); > + rows =3D (Integer)fetch.getHint("openjpa.hint.optimize"); > + optimizeString.append("=20 > ").append(optimizeClause).append(" ") > + .append(rows).append(" "); > + if(rows.intValue() > 1) > + optimizeString.append(rowsClause).append(" "); > + else > + optimizeString.append(rowClause).append(" "); > + } > + return optimizeString.toString(); =20 > } > } >=20 > Modified:=20 > incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/ openjpa/jdbc/sql/DBDictionary.java > URL:=20 > http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-j dbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?> view=3Ddiff&rev=3D510281&r1=3D510280&r2=3D510281 > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > ---=20 > incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/ openjpa/jdbc/sql/DBDictionary.java (original) > +++=20 > incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/ openjpa/jdbc/sql/DBDictionary.java Wed Feb 21 14:50:04 2007 > @@ -184,6 +184,9 @@ > public String crossJoinClause =3D "CROSS JOIN"; > public boolean requiresConditionForCrossJoin =3D false; > public String forUpdateClause =3D "FOR UPDATE"; > + public String optimizeClause =3D null; > + public String rowClause =3D "row"; > + public String rowsClause =3D "rows"; > public String tableForUpdateClause =3D null; > public String distinctCountColumnSeparator =3D null; > public boolean supportsSelectForUpdate =3D true; > @@ -2143,10 +2146,22 @@ > SQLBuffer from, SQLBuffer where, SQLBuffer group, > SQLBuffer having, SQLBuffer order, > boolean distinct, boolean forUpdate, long start, long end) { > - return toOperation(getSelectOperation(fetch),=20 > selects, from, where, > + =09 > + String optimizeString =3D null; > + SQLBuffer selString =3D = toOperation(getSelectOperation(fetch),=20 > + selects, from, where, > group, having, order, distinct, forUpdate, start, end); > + if (fetch !=3D null) > + optimizeString =3D getOptimizeClause(fetch); > + if (optimizeString !=3D null) > + selString.append(optimizeString); > + return selString; =09 > } > =20 > + public String getOptimizeClause(JDBCFetchConfiguration fetch) { > + return null; =09 > + } > + =20 > /** > * Return the "SELECT" operation clause, adding any=20 > available hints, etc. > */ >=20 > Modified:=20 > incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apach e/openjpa/kernel/BrokerImpl.java > URL:=20 > http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-k ernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java?> view=3Ddiff&rev=3D510281&r1=3D510280&r2=3D510281 > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > ---=20 > incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apach e/openjpa/kernel/BrokerImpl.java (original) > +++=20 > incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apach e/openjpa/kernel/BrokerImpl.java Wed Feb 21 14:50:04 2007 > @@ -765,7 +765,7 @@ > } > if (fetch =3D=3D null) > fetch =3D _fc; > - > + fetch.setHint("openjpa.hint.optimize", new Integer(1)); > beginOperation(true); > try { > assertNontransactionalRead(); >=20 > Modified:=20 > incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/ apache/openjpa/persistence/QueryImpl.java > URL:=20 > http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-p ersistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java?> view=3Ddiff&rev=3D510281&r1=3D510280&r2=3D510281 > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > ---=20 > incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/ apache/openjpa/persistence/QueryImpl.java (original) > +++=20 > incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/ apache/openjpa/persistence/QueryImpl.java Wed Feb 21 14:50:04 2007 > @@ -279,6 +279,8 @@ > */ > public Object getSingleResult() { > _em.assertNotCloseInvoked(); > + _query.getFetchConfiguration(). > + setHint("openjpa.hint.optimize", new Integer(1)); > Object ob =3D execute(); > if (!(ob instanceof List)) > return ob; >=20 >=20 >=20