From commits-return-2348-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Sun Sep 02 06:53:31 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 90687 invoked from network); 2 Sep 2007 06:53:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Sep 2007 06:53:30 -0000 Received: (qmail 51112 invoked by uid 500); 2 Sep 2007 06:53:25 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 51092 invoked by uid 500); 2 Sep 2007 06:53:25 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 51083 invoked by uid 99); 2 Sep 2007 06:53:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Sep 2007 23:53:25 -0700 X-ASF-Spam-Status: No, hits=-96.3 required=10.0 tests=ALL_TRUSTED,HTML_MESSAGE,MIME_HTML_ONLY X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Sep 2007 06:53:20 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 0CA96714163 for ; Sat, 1 Sep 2007 23:53:00 -0700 (PDT) Message-ID: <21653487.1188715980024.JavaMail.www-data@brutus> Date: Sat, 1 Sep 2007 23:53:00 -0700 (PDT) From: confluence@apache.org To: commits@openjpa.apache.org Subject: [CONF] OpenJPA: Powered By (page edited) MIME-Version: 1.0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org
Page Edited : = openjpa : Powered By

Powered By has been edited by Patrick Linskey (Sep 01, 2007).

=20

(View changes)

Content:

This page list products and companies that are currently using OpenJPA.<= /p>
Active= MQ3D"": Apache ActiveMQ is the most popular and powerful open sourc= e Message Broker which supports many Cross Language Clients and Protocols a= nd many advanced features while fully supporting JMS 1.1 and J2EE 1.4. Open= JPA is included with ActiveMQ version 4.2 and later.
BEA WebLogic Se= rver3D""<= /sup>: WebLogic Server 10 and later use Kodo as the default JPA = implementation, and for various internal services. Kodo, in turn, includes = OpenJPA.
BEA Kodo3D"": Kodo is the project from which the OpenJPA source code was derive= d. Kodo is now, in turn, based on the Apache OpenJPA project and is in prod= uction use in hundreds of mission-critical applications around the world. O= penJPA is included as part of Kodo 4.1 and higher
Camel3D"": Apache Camel is a POJO based routing and mediation libr= ary for implementing the Enterprise Integration Patterns in Java<= sup>3D""= . OpenJPA is included from the very first version of Camel for u= se with the camel-= jpa module3D""
Geron= imo3D"": The Geronimo project is a free software application server= developed by the Apache Software Foundation and distributed under the Apac= he license. The goal of the Geronimo project is to produce a server runtime= framework that pulls together the best Open Source alternatives to create = runtimes that meet the needs of developers and system administrators. OpenJ= PA is shipped as part of Geronimo 1.2 beta and 2.0-m1.

Apache O= de

= Ode3D"": Ode (Orchestration Director Engine) is an Apache incubated= project to develop an open-source, Apache-licensed, implementation of the = WS-BPEL 1.1 and WS-BPEL 2.0 (draft) specifications. Ode is a choreography e= ngine allowing you to develop processes to call services in a well-defined = manner. OpenJPA is included with Ode version 2.0 and later.
OpenEJB3D"": OpenEJB is an open source, modular, configurable= , and extendable EJB Container System and EJB Server. OpenJPA is included w= ith OpenEJB version 3.0 and later.
Sp= ring3D""<= /sup>: The popular Spring framework is the leading full-stack Ja= va/J2EE application framework, delivering significant benefits for many pro= jects, reducing development effort and costs while improving test coverage = and quality. OpenJPA is shipped as part of Spring 2.0.1
WebSphere Application Server Ve= rsion 6.1 Feature Pack for EJB 3 Alpha3D"": The Alpha release of t= he IBM WebSphere Application Server Feature Pack for EJB 3.0 contains a pre= liminary implementation of the Enterprise JavaBeans Version 3.0 specificati= on, commonly known as EJB3. Associated with the Enterprise JavaBeans Versi= on 3.0 specification is the Java Persistence API specification, commonly kn= own as JPA. The Alpha JPA implementation is powered by OpenJPA.
= Compass3D"" is a first class open source Java Search Engine Framewo= rk, enabling the power of Search Engine semantics to your application stack= decoratively. Compass has "native" integration with OpenJPA by working in = an "embedded" mode within it. OpenJPA can be used with JPA and Compass has = specific indexer and lifecycle for it, but Compass can also work from withi= n OpenJPA and have OpenJPA control Compass creation and configuration.

From commits-return-2349-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Tue Sep 04 02:05:39 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 10779 invoked from network); 4 Sep 2007 02:05:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Sep 2007 02:05:39 -0000 Received: (qmail 84078 invoked by uid 500); 4 Sep 2007 02:05:33 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 84059 invoked by uid 500); 4 Sep 2007 02:05:33 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 84050 invoked by uid 99); 4 Sep 2007 02:05:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Sep 2007 19:05:33 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Sep 2007 02:05:37 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 862381A9832; Mon, 3 Sep 2007 19:05:17 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r572492 - in /openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/ openjpa-kernel/src/main/java/org/apache/openjpa/meta/ openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/jpql/ openjpa-kernel/src/main/resour... Date: Tue, 04 Sep 2007 02:05:16 -0000 To: commits@openjpa.apache.org From: pcl@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070904020517.862381A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pcl Date: Mon Sep 3 19:05:15 2007 New Revision: 572492 URL: http://svn.apache.org/viewvc?rev=572492&view=rev Log: Improve error messages when processing metadata / JPQL queries. Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/JPQLExpressionBuilder.java openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/jpql/localizer.properties openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestSimpleXmlEntity.java Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/JPQLExpressionBuilder.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/JPQLExpressionBuilder.java?rev=572492&r1=572491&r2=572492&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/JPQLExpressionBuilder.java (original) +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/JPQLExpressionBuilder.java Mon Sep 3 19:05:15 2007 @@ -164,11 +164,17 @@ if (c != null) cmd = repos.getMetaData(c, loader, assertValid); else if (assertValid) - cmd = repos.getMetaData(alias, loader, true); + cmd = repos.getMetaData(alias, loader, false); - if (cmd == null && assertValid) - throw parseException(EX_USER, "not-schema-name", - new Object[]{ alias }, null); + if (cmd == null && assertValid) { + String close = repos.getClosestAliasName(alias); + if (close != null) + throw parseException(EX_USER, "not-schema-name-hint", + new Object[]{ alias, close, repos.getAliasNames() }, null); + else + throw parseException(EX_USER, "not-schema-name", + new Object[]{ alias, repos.getAliasNames() }, null); + } return cmd; } Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java?rev=572492&r1=572491&r2=572492&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java (original) +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java Mon Sep 3 19:05:15 2007 @@ -47,6 +47,7 @@ import org.apache.openjpa.lib.util.Closeable; import org.apache.openjpa.lib.util.J2DoPrivHelper; import org.apache.openjpa.lib.util.Localizer; +import org.apache.openjpa.lib.util.StringDistance; import org.apache.openjpa.util.ImplHelper; import org.apache.openjpa.util.InternalException; import org.apache.openjpa.util.MetaDataException; @@ -360,8 +361,7 @@ // maybe this is some type we've seen but just isn't valid if (_aliases.containsKey(alias)) { if (mustExist) - throw new MetaDataException(_loc.get("no-alias-meta", alias, - _aliases.toString())); + throwNoRegisteredAlias(alias); return null; } @@ -370,7 +370,43 @@ if (!mustExist) return null; - throw new MetaDataException(_loc.get("no-alias-meta", alias, _aliases)); + return throwNoRegisteredAlias(alias); + } + + private ClassMetaData throwNoRegisteredAlias(String alias) { + String close = getClosestAliasName(alias); + if (close != null) + throw new MetaDataException( + _loc.get("no-alias-meta-hint", alias, _aliases, close)); + else + throw new MetaDataException( + _loc.get("no-alias-meta", alias, _aliases)); + } + + /** + * @return the nearest match to the specified alias name + * @since 1.1.0 + */ + public String getClosestAliasName(String alias) { + Collection aliases = getAliasNames(); + return StringDistance.getClosestLevenshteinDistance(alias, aliases); + } + + /** + * @return the registered alias names + * @since 1.1.0 + */ + public Collection getAliasNames() { + Collection aliases = new HashSet(); + synchronized (_aliases) { + for (Iterator iter = _aliases.entrySet().iterator(); + iter.hasNext(); ) { + Map.Entry e = (Map.Entry) iter.next(); + if (e.getValue() != null) + aliases.add(e.getKey()); + } + } + return aliases; } /** Modified: openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/jpql/localizer.properties URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/jpql/localizer.properties?rev=572492&r1=572491&r2=572492&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/jpql/localizer.properties (original) +++ openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/jpql/localizer.properties Mon Sep 3 19:05:15 2007 @@ -36,7 +36,10 @@ wrong-child-count: Wrong number of arguments to expression \ of type "{1}": should have been {0}, but the following arguments \ were specified: "{2}". -not-schema-name: The name "{0}" is not a recognized entity or identifier. +not-schema-name: The name "{0}" is not a recognized entity or identifier. \ + Known entity names: {1} +not-schema-name-hint: The name "{0}" is not a recognized entity or identifier. \ + Perhaps you meant {1}, which is a close match. Known entity names: {2} duplicate-alias: Alias "{0}" was declared twice. unknown-type: Cannot determine the type of field "{0}". unexpected-var: The variable "{0}" was found where a constant or \ Modified: openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties?rev=572492&r1=572491&r2=572492&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties (original) +++ openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties Mon Sep 3 19:05:15 2007 @@ -142,9 +142,15 @@ if you list your persistent classes, the class is included in your list. no-oid-meta: Could not locate metadata for the class using oid "{0}" of \ type "{1}". Registered oid type mappings: "{2}" -no-alias-meta: Could not locate metadata for the class using alias "{0}". This \ - could mean that the OpenJPA enhancer or load-time weaver was not run on \ - the type whose alias is "{0}". Registered alias mappings: "{1}" +no-alias-meta: Could not locate metadata for the class using alias "{0}". \ + This could mean that you have mis-spelled the alias, or that OpenJPA failed\ + to properly load the metadata for the type whose alias is "{0}". \ + Registered alias mappings: "{1}" +no-alias-meta-hint: Could not locate metadata for the class using alias "{0}". \ + Perhaps you meant {2}, which is a close match. \ + This could mean that you have mis-spelled the alias, or that OpenJPA failed\ + to properly load the metadata for the type whose alias is "{0}". \ + Registered alias mappings: "{1}" error-registered: An error occurred while processing registered class "{0}". failed-registered: A potentially serious error occurred while processing \ registered class "{0}". Deferring processing of this class until next \ Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestSimpleXmlEntity.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestSimpleXmlEntity.java?rev=572492&r1=572491&r2=572492&view=diff ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestSimpleXmlEntity.java (original) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestSimpleXmlEntity.java Mon Sep 3 19:05:15 2007 @@ -53,7 +53,8 @@ fail("should not be able to execute query using short class name " + "for entity that has an entity name specified"); } catch (ArgumentException ae) { - // expected + assertTrue( + ae.getMessage().indexOf("Perhaps you meant SimpleXml,") != -1); } } @@ -67,7 +68,8 @@ fail("should not be able to execute query using short class name " + "for entity that has an entity name specified"); } catch (ArgumentException ae) { - // expected + assertTrue( + ae.getMessage().indexOf("Perhaps you meant SimpleXml,") != -1); } } } From commits-return-2350-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Tue Sep 04 17:56:01 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 35858 invoked from network); 4 Sep 2007 17:56:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Sep 2007 17:56:01 -0000 Received: (qmail 75643 invoked by uid 500); 4 Sep 2007 17:55:56 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 75587 invoked by uid 500); 4 Sep 2007 17:55:56 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 75574 invoked by uid 99); 4 Sep 2007 17:55:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Sep 2007 10:55:55 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Sep 2007 17:56:00 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 518BE1A9832; Tue, 4 Sep 2007 10:55:40 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r572758 - in /openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa: conf/MetaDataCacheMaintenance.java meta/MetaDataModes.java Date: Tue, 04 Sep 2007 17:55:39 -0000 To: commits@openjpa.apache.org From: pcl@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070904175540.518BE1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pcl Date: Tue Sep 4 10:55:39 2007 New Revision: 572758 URL: http://svn.apache.org/viewvc?rev=572758&view=rev Log: OPENJPA-344. Increase the footprint of metadata that is gathered during the MetaDataCacheMaintenance storage process. Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/MetaDataCacheMaintenance.java openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataModes.java Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/MetaDataCacheMaintenance.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/MetaDataCacheMaintenance.java?rev=572758&r1=572757&r2=572758&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/MetaDataCacheMaintenance.java (original) +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/MetaDataCacheMaintenance.java Tue Sep 4 10:55:39 2007 @@ -95,9 +95,7 @@ public void store() { MetaDataRepository repos = conf.getMetaDataRepositoryInstance(); - repos.setSourceMode(MetaDataRepository.MODE_META - | MetaDataRepository.MODE_MAPPING - | MetaDataRepository.MODE_QUERY); + repos.setSourceMode(MetaDataRepository.MODE_ALL); Collection types = repos.loadPersistentTypes(devpath, null); for (Iterator iter = types.iterator(); iter.hasNext(); ) repos.getMetaData((Class) iter.next(), null, true); Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataModes.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataModes.java?rev=572758&r1=572757&r2=572758&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataModes.java (original) +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataModes.java Tue Sep 4 10:55:39 2007 @@ -33,4 +33,7 @@ public static final int MODE_QUERY = 4; public static final int MODE_MAPPING_INIT = 8; public static final int MODE_ANN_MAPPING = 16; + + public static final int MODE_ALL = MODE_META | MODE_MAPPING | MODE_QUERY + | MODE_MAPPING_INIT | MODE_ANN_MAPPING; } From commits-return-2351-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Wed Sep 05 06:41:09 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 97933 invoked from network); 5 Sep 2007 06:41:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Sep 2007 06:41:09 -0000 Received: (qmail 8879 invoked by uid 500); 5 Sep 2007 06:41:04 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 8860 invoked by uid 500); 5 Sep 2007 06:41:04 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 8851 invoked by uid 99); 5 Sep 2007 06:41:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Sep 2007 23:41:04 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Sep 2007 06:42:23 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id C079C1A9832; Tue, 4 Sep 2007 23:40:45 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r572886 - /openjpa/trunk/openjpa-all/pom.xml Date: Wed, 05 Sep 2007 06:40:45 -0000 To: commits@openjpa.apache.org From: pcl@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070905064045.C079C1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pcl Date: Tue Sep 4 23:40:44 2007 New Revision: 572886 URL: http://svn.apache.org/viewvc?rev=572886&view=rev Log: OPENJPA-345 Modified: openjpa/trunk/openjpa-all/pom.xml Modified: openjpa/trunk/openjpa-all/pom.xml URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-all/pom.xml?rev=572886&r1=572885&r2=572886&view=diff ============================================================================== --- openjpa/trunk/openjpa-all/pom.xml (original) +++ openjpa/trunk/openjpa-all/pom.xml Tue Sep 4 23:40:44 2007 @@ -80,6 +80,48 @@ + + + org.apache.openjpa + openjpa-lib + ${pom.version} + + + org.apache.openjpa + openjpa-kernel + ${pom.version} + + + org.apache.openjpa + openjpa-kernel-5 + ${pom.version} + + + org.apache.openjpa + openjpa-jdbc + ${pom.version} + + + org.apache.openjpa + openjpa-jdbc-5 + ${pom.version} + + + org.apache.openjpa + openjpa-persistence + ${pom.version} + + + org.apache.openjpa + openjpa-persistence-jdbc + ${pom.version} + + + org.apache.openjpa + openjpa-xmlstore + ${pom.version} + +
Page Edited : = openjpa : Releasing OpenJPA

Releasing OpenJPA has been edited by Michael Dick (Sep 06, 2007).

Change summary:

Explicitly set permissions on = /www/www.apache.org/dist/openjpa/x.y.z

(View changes)

Content:

Making an OpenJ= PA Release

These instructions guide the release manager through the steps of making= an official OpenJPA release.

Prerequisites

    =09
  1. You should read the OpenJPA Release Policy to= decide on the name of the new release, based on the content.
  2. =09
  3. You should read the Apache Release FAQ=3D""
  4. =09
  5. You must have shell access to people.apache.org
  6. =09
  7. You must have the following utilities installed on your local machin= e and available in your path:

<= /a>Tasks that need to be performed for each release

3D""In the examples below, it is assumed that the release nam= e will be 1.0.1, and that the current checked-in version name is = 1.0.1-SNAPSHOT and stored in the branch named 1.0.x.
Monday, 12:00 Make sure the One time setup = steps have been performed
Monday, 12:01 Create a sub-branch off of the parent branch fr= om which to make the release. Releasing from a branch will allow any cosmet= ic changes that need to be made for the release to be approved to be done w= ithout preventing other more disruptive advances in the trunk from potentia= lly causing problems with the release. A branch can be made by running:
svn copy -m "OpenJPA Release 1.0.1 branch" \
  https://svn.apache.org/repos/asf/openjpa/branches/1.0.x \
  https://svn.apache.org/repos/asf/openjpa/branches/1.0.1
Monday, 12:02 Check out a clean branch from which to build th= e release:
svn checkout https://svn.apache.org/repos/asf/open=
jpa/branches/1.0.1
cd 1.0.1
Monday, 12:03 Update all the POMs to remove "-SNAPSHOT" suffi= x from the version. If you have perl installed, you can easily do it with a= single command:
perl -pi -e "s;<version>1.0.1-SNAPSHOT</v=
ersion>;<version>1.0.1</version>;g" \
    pom.xml */pom.xml */*/pom.xml
Monday, 12:10 Verify that LICENSE.txt contains up to date lic= enses for any dependencies which are included in our distribution.
Any jars or source code which is included with the OpenJPA dist= ribution that is not covered by the Apache license must be noted in LICENSE= .txt. Two examples of this are the persistence and orm dtds (licensed under= the CDDL) and Serp. If any new non Apache dependencies have been introduce= d they will have to be covered here as well. If any discrepancies are found= update LICENSE.txt and commit the changes.
Monday, 12:15 Update BUILDING.txt, CHANGES.txt and RELEASE-NO= TES.html
    =09
  • BUILDING.txt should be included in the source tarball and contains i= nstructions on how to build OpenJPA. Prior to shipping a release we should = ensure that those instructions are accurate.
  • =09
  • CHANGES.txt contains a text representation of all the changes which = have been made since the preceding release. Most of the contents of this fi= le can be generated through JIRA's release notes mechanism here3D""
  • =09
  • RELEASE-NOTES.html contains general information on the OpenJPA proje= ct as well as an html version of the changes since the preceding version. T= he html change log may also be generated via JIRA.
Monday, 12:20 Commit the POM changes
svn commit -m "Updated to version 1.0.1 for the re=
lease"
Monday, 12:21 Perform an initial build and install it in the = local repository (this step is only required because of an open bug3D"" with Maven= 's javadoc plugin):
mvn clean install -Dtest=3Dfalse
Monday, 12:23 Now build the release locally, which will build= and test, run the Apache Release Audit Tool to verify license headers, generate= the javadoc and docbook PDF and HTML, run through the JPA TCK, build the s= ource and binariy assemblies in target/site/downloads/, and sign the= release files.
export MAVEN_OPTS=3D-Xmx1000m
mvn --batch-mode deploy site \
    -Ptck-profile,examples-profile,license-verify-profile,javadoc-profile,d=
ocbook-profile,sign-release \
    -Djava14.jar=3D${JAVA_HOME}/../../1.4/Classes/classes.jar \
    -Dtck.zip=3D${HOME}/.m2/privaterepos/jpa-1_0b-tck.zip

3D""This operation will also sign the release files with the gpg utility using the <username>@apache.org key. If your code si= gning key is under a different address, specify it by appending the followi= ng argument to the command above: -Dopenjpa.release.keyAlias=3Dmysignin= galias@somedomain.org

3D""The java14.jar path should be changed to the local i= nstall path for the JDK 1.4 rt.jar so that JDK 1.4 verification can take pl= ace.

3D""The tck.zip path should be changed to the local inst= all path to the JPA TCK so that the TCK can be run against the release.
Monday, 13:00 Verify the signatures:
gpg --multifile --verify target/site/downloads/*.a=
sc
Monday, 13:01 Upload the release candidate to http://openjpa.apache.o= rg/builds/1.0.1/downloads/:
mvn site:deploy
3D""

Bear in mind that uploads to people.apache.org/www/openjpa.apache.org= /builds/ are not visible at http://openjpa.apache.org/builds3D"" until after the hourly sy= nchronization has taken place, as described at http://www.apache.org/dev/project-site.html<= sup>3D""= .

Monday, 15:00 Start a vote for the release on the dev@openjpa.apache.org3D"" mailing list. Votes made by committers and members of the OpenJPA proje= ct are considered binding for this vote. For an example of the mail, see this archived 1.0.0 vote3D""
Tuesday, Wednesday While waiting for the vote to complete, perform= whatever manual review and testing on the release you deem appropriate.
Thursday, 15:00 If the vote is successful after 3 days tally th= e votes in an email to d= ev@openjpa.apache.org=3D"", like this one3D"".
Thursday, 15:10 Make the OpenJPA assemblies available to the Ap= ache mirroring system by copying them over on people.apache.org:
ssh people.apache.org
cp -r /www/openjpa.apache.org/builds/1.0.1/downloads /www/www.apache.org/di=
st/openjpa/1.0.1
chgrp -R openjpa /www/www.apache.org/dist/openjpa/1.0.1
chmod -R g+w /www/www.apache.org/dist/openjpa/1.0.1
3D""

The OpenJPA binary release will be available via the link http://www.apache.org/dyn/closer.cgi/openjpa/1.0.1/apache-openjpa-= 1.0.1-binary.zip3D"" after 24 hours, as per the Apache mirroring information3D"".

Thursday, 15:15 Now that the release is locked down, convert th= e writeable 1.0.1 branch to a (du jure) read-only tag:
svn mv -m "OpenJPA Release 1.0.1 tag" \
  https://svn.apache.org/repos/asf/openjpa/branches/1.0.1 \
  https://svn.apache.org/repos/asf/openjpa/tags/1.0.1
Thursday, 15:16 Check out the parent branch and bump up the rel= ease number to be the next snapshot version:
svn checkout https://svn.apache.org/repos/asf/open=
jpa/branches/1.0.x
cd 1.0.x
perl -pi -e "s;<version>1.0.1-SNAPSHOT</version>;<version>=
;1.0.2-SNAPSHOT</version>;g" \
    pom.xml */pom.xml */*/pom.xml
svn commit -m "Updating version in branch to 1.0.2-SNAPSHOT"
Thursday, 15:20 Update the http://cwiki.apache.org/openjpa/downloads.html3D"" page with links to the download mirrors, using the existing entri= es as templates.
3D""All artifacts (apache-openjpa-1.0.1-binar= y.zip and apache-openjpa-1.0.1-source.zip) must link to t= he mirrors, but signatures (apache-openjpa-1.0.1-binary.zip.asc and = apache-openjpa-1.0.1-source.zip.asc) must not link to mirrors= .
Thursday, 15:30 The documentation on the server-side must manua= lly be extracted on people.apache.org, and the links at http://openjpa.apache.org/= documentation.html3D"" need to be updated with the new versions and= the "latest" documentation symbolic links need to be updated:
cd /www/openjpa.apache.org/builds/1.0.1/
unzip downloads/apache-openjpa-1.0.1-binary.zip
rm /www/openjpa.apache.org/docs/latest
ln -fvs ../builds/1.0.1/apache-openjpa-1.0.1/docs/ /www/openjpa.apache.org/=
docs/latest

Then point the links on http://openjpa.apache.org/documentation.html3D"" to:
Thursday, 15:45 Merge the staged maven2 repository jars to with= the official repository to rsync. This is currently a difficult process th= at requires the maven-staging-plugin, which much be built from sourc= e. The process looks something like this (executed in the root of your loca= l OpenJPA checkout):
svn co http://svn.apache.org/repos/asf/maven/plugi=
ns/trunk/maven-stage-plugin/ \
    /tmp/maven-stage-plugin
mvn -f /tmp/maven-stage-plugin/pom.xml clean install
find . \
    -name m2-repository -not -path "*openjpa-project*" \
    -exec mvn -f /tmp/maven-stage-plugin \
    stage:copy -Dsource=3Dfile://{} \
    -Dtarget=3Dscp://people.apache.org/www/people.apache.org/repo/m2-ibibli=
o-rsync-repository \
    -Dversion=3D1.0.1 \;
3D""

This process requires Maven 2.0.5. It is currently quite delicate and er= ror-prone. Once the maven-stage-plugin is released, it should be pos= sible to make it more automated.

Thursday, 16:00 Update the JIRA versions <= sup>3D""= page to mark the version as "released", and set the date to the= date that the release was approved. You may also need to make a new releas= e entry for the subsequent release.
Friday, 16:00 After the mirrors have had time to update (24 h= ours to be on the safe side), make a news announcemen= t3D"" on the OpenJPA wiki.
3D""Once the news item is made= , it won't show up on the f= ront page3D"" unless you make some minor edit to the containing pag= e (e.g., adding a newline somewhere).
Friday, 16:05 Make an announcement about the release on the <= span class=3D"nobr">users@openjpa.apache.= org3D"" list (and, for major releases, on the announce@apache.org3D"" list as per= the Apache Announcement Mailing Lists page3D""). The = announcement might look something like this3D"". =
Friday, 16:10 Make an announcement for the freshmeat.net OpenJPA project3D"" (optional)
Friday, 17:00 Have a beer and enjoy your weekend while the wo= rld's grateful programmers revel in yet another high-quality release of Apa= che OpenJPA!

One time setup

These setup steps only need to be performed on a particular machine once= .

3D""Developers using Linux workstations can skip over the ref= erences to PuTTY and Cygwin

Create and ins= tall a SSH key

1 Install PuTTY
2 Use PuttyGen to create a SSH key (see Putty hel= p for details)
3 Use PuTTY to ssh to people.apache.org
4 Create a ~/.ssh folder
5 pscp your SSH public key to ~= /authorized_keys
6 ssh to people.apache.org
7 Create a ~\.ssh folder and move a= uthorized_keys there
8 Configure putty to use your private key and sav= e the session

Create a PGP key

1 Install cgywin, including utils/gpg
2 Generate a key with $ gpg --gen-key
3 Backup your cygwin home directory to another me= dia
4 Add your key to https://svn.apache.org/repos/as= f/openjpa/site/docs/KEYS=3D""

Updat= e Maven settings for our servers

1 Create a settings.xml under .m2 (in your Docume= nt and Settings folder in Windows)
 
se= ttings.xml
<settings xmlns=3D"ht=
tp://maven.apache.org/POM/4.0.0"
          xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation=3D"http://maven.apa=
che.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">=
;
    <servers>
       <server>
          <id>people.apache.org</id>
          <username>$USERNAME</username>
          <privateKey>$PATH_TO_PRIVAT=
E_KEY</privateKey>
          <directoryPermissions>775</directoryPermissions>
          <filePermissions>644</filePermissions>
       </server>
    </servers>   =20
</settings>

Expose = a copy of known hosts to Maven

1 From cygwin, ssh to people.apache.org, save the= public key if prompted, and exit
  cygwin will save the known hosts to your &#= 126;/.ssh folder, but the script cannot access it there (from Windows)=
2 From cygwin (not Windows) create another .s= sh folder at 3D=
3 Copy the known_hosts file to the new <= tt>.ssh folder

Resources

From commits-return-2353-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Thu Sep 06 21:47:21 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 89855 invoked from network); 6 Sep 2007 21:47:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Sep 2007 21:47:21 -0000 Received: (qmail 34002 invoked by uid 500); 6 Sep 2007 21:47:15 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 33947 invoked by uid 500); 6 Sep 2007 21:47:15 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 33936 invoked by uid 99); 6 Sep 2007 21:47:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Sep 2007 14:47:15 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Sep 2007 21:48:40 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6E4821A9832; Thu, 6 Sep 2007 14:46:58 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r573391 - /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java Date: Thu, 06 Sep 2007 21:46:58 -0000 To: commits@openjpa.apache.org From: pcl@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070906214658.6E4821A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pcl Date: Thu Sep 6 14:46:57 2007 New Revision: 573391 URL: http://svn.apache.org/viewvc?rev=573391&view=rev Log: Removing numeric constant in favor of JDK1.4 literal, now that OpenJPA requires 1.4. Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=573391&r1=573390&r2=573391&view=diff ============================================================================== --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java (original) +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java Thu Sep 6 14:46:57 2007 @@ -1532,7 +1532,7 @@ return bitTypeName; case Types.BLOB: return blobTypeName; - case 16: // JDK 1.4 introduces Types.BOOLEAN, whose value is 16 + case Types.BOOLEAN: return booleanTypeName; case Types.CHAR: return charTypeName; @@ -2518,7 +2518,7 @@ * @param val the value to cast * @param type the type of the case, e.g. {@link Types#NUMERIC} */ - public void appendCast(SQLBuffer buf, FilterValue val, int type) { + public void appendCast(SQLBuffer buf, Object val, int type) { // Convert the cast function: "CAST({0} AS {1})" int firstParam = castFunction.indexOf("{0}"); String pre = castFunction.substring(0, firstParam); // "CAST(" @@ -2532,7 +2532,12 @@ post = ""; buf.append(pre); - val.appendTo(buf); + if (val instanceof FilterValue) + ((FilterValue) val).appendTo(buf); + else if (val instanceof SQLBuffer) + buf.append(((SQLBuffer) val)); + else + buf.append(val.toString()); buf.append(mid); buf.append(getTypeName(type)); appendLength(buf, type); From commits-return-2354-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Thu Sep 06 22:16:35 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 3442 invoked from network); 6 Sep 2007 22:16:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Sep 2007 22:16:34 -0000 Received: (qmail 1277 invoked by uid 500); 6 Sep 2007 22:16:29 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 1263 invoked by uid 500); 6 Sep 2007 22:16:29 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 1254 invoked by uid 99); 6 Sep 2007 22:16:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Sep 2007 15:16:29 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Sep 2007 22:16:33 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id CA36F1A9832; Thu, 6 Sep 2007 15:16:12 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r573398 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/InValueDiscriminatorStrategy.java openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java Date: Thu, 06 Sep 2007 22:16:12 -0000 To: commits@openjpa.apache.org From: mikedd@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070906221612.CA36F1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mikedd Date: Thu Sep 6 15:16:10 2007 New Revision: 573398 URL: http://svn.apache.org/viewvc?rev=573398&view=rev Log: OPENJPA-353 Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/InValueDiscriminatorStrategy.java openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/InValueDiscriminatorStrategy.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/InValueDiscriminatorStrategy.java?rev=573398&r1=573397&r2=573398&view=diff ============================================================================== --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/InValueDiscriminatorStrategy.java (original) +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/InValueDiscriminatorStrategy.java Thu Sep 6 15:16:10 2007 @@ -112,7 +112,8 @@ && base.getJoinablePCSubclassMappings().length == 0)) return base.getDescribedType(); - Object cls = res.getObject(disc.getColumns()[0], -1, null); + Object cls = + res.getObject(disc.getColumns()[0], disc.getJavaType(), null); return getClass(cls, store); } Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java?rev=573398&r1=573397&r2=573398&view=diff ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java (original) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java Thu Sep 6 15:16:10 2007 @@ -50,7 +50,24 @@ discrim = getMapping("CharRootEntity").getDiscriminator(); assertEquals(new Character('R'), discrim.getValue()); assertEquals(JavaTypes.CHAR, discrim.getJavaType()); - + + CharLeafEntity leaf = new CharLeafEntity(); + CharRootEntity root = new CharRootEntity(); + em.getTransaction().begin(); + em.persist(leaf); + em.persist(root); + em.getTransaction().commit(); + + em.refresh(leaf); + em.refresh(root); + + em.clear(); + + CharLeafEntity leaf2 = em.find(CharLeafEntity.class, leaf.getId()); + CharRootEntity root2 = em.find(CharRootEntity.class, root.getId()); + + assertNotNull(leaf2); + assertNotNull(root2); em.close(); } @@ -71,6 +88,25 @@ assertEquals(new Integer(10101), discrim.getValue()); assertEquals(JavaTypes.INT, discrim.getJavaType()); + IntegerLeafEntity leaf = new IntegerLeafEntity(); + IntegerRootEntity root = new IntegerRootEntity(); + em.getTransaction().begin(); + em.persist(leaf); + em.persist(root); + em.getTransaction().commit(); + + em.refresh(leaf); + em.refresh(root); + + em.clear(); + + IntegerLeafEntity leaf2 = + em.find(IntegerLeafEntity.class, leaf.getId()); + IntegerRootEntity root2 = + em.find(IntegerRootEntity.class, root.getId()); + + assertNotNull(leaf2); + assertNotNull(root2); em.close(); } @@ -88,6 +124,24 @@ discrim = getMapping("StringRootEntity").getDiscriminator(); assertEquals("StringRoot", discrim.getValue()); assertEquals(JavaTypes.STRING, discrim.getJavaType()); + + StringLeafEntity leaf = new StringLeafEntity(); + StringRootEntity root = new StringRootEntity(); + em.getTransaction().begin(); + em.persist(leaf); + em.persist(root); + em.getTransaction().commit(); + + em.refresh(leaf); + em.refresh(root); + + em.clear(); + + StringLeafEntity leaf2 = em.find(StringLeafEntity.class, leaf.getId()); + StringRootEntity root2 = em.find(StringRootEntity.class, root.getId()); + + assertNotNull(leaf2); + assertNotNull(root2); em.close(); } From commits-return-2355-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Fri Sep 07 18:11:18 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 96111 invoked from network); 7 Sep 2007 18:11:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Sep 2007 18:11:18 -0000 Received: (qmail 38497 invoked by uid 500); 7 Sep 2007 18:11:12 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 38439 invoked by uid 500); 7 Sep 2007 18:11:12 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 38429 invoked by uid 99); 7 Sep 2007 18:11:11 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Sep 2007 11:11:11 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Sep 2007 18:12:28 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 033E31A983E; Fri, 7 Sep 2007 11:10:44 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r573653 - /openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log4JLogFactory.java Date: Fri, 07 Sep 2007 18:10:43 -0000 To: commits@openjpa.apache.org From: clr@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070907181044.033E31A983E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: clr Date: Fri Sep 7 11:10:43 2007 New Revision: 573653 URL: http://svn.apache.org/viewvc?rev=573653&view=rev Log: OPENJPA-355 Fix checking for log levels; patch submitted by Adrian Co" Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log4JLogFactory.java Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log4JLogFactory.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log4JLogFactory.java?rev=573653&r1=573652&r2=573653&view=diff ============================================================================== --- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log4JLogFactory.java (original) +++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log4JLogFactory.java Fri Sep 7 11:10:43 2007 @@ -49,23 +49,23 @@ } public boolean isTraceEnabled() { - return _log.getEffectiveLevel().toInt() >= Level.DEBUG_INT; + return _log.isEnabledFor(Level.DEBUG); } public boolean isInfoEnabled() { - return _log.getEffectiveLevel().toInt() >= Level.INFO_INT; + return _log.isEnabledFor(Level.INFO); } public boolean isWarnEnabled() { - return _log.getEffectiveLevel().toInt() >= Level.WARN_INT; + return _log.isEnabledFor(Level.WARN); } public boolean isErrorEnabled() { - return _log.getEffectiveLevel().toInt() >= Level.ERROR_INT; + return _log.isEnabledFor(Level.ERROR); } public boolean isFatalEnabled() { - return _log.getEffectiveLevel().toInt() >= Level.FATAL_INT; + return _log.isEnabledFor(Level.FATAL); } public void trace(Object o) { From commits-return-2356-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Fri Sep 07 19:24:08 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 36820 invoked from network); 7 Sep 2007 19:24:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Sep 2007 19:24:06 -0000 Received: (qmail 82476 invoked by uid 500); 7 Sep 2007 19:24:00 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 82423 invoked by uid 500); 7 Sep 2007 19:23:59 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 82114 invoked by uid 99); 7 Sep 2007 19:23:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Sep 2007 12:23:59 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Sep 2007 19:25:16 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 735511A9832; Fri, 7 Sep 2007 12:23:30 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r573675 - /openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log4JLogFactory.java Date: Fri, 07 Sep 2007 19:23:30 -0000 To: commits@openjpa.apache.org From: pcl@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070907192330.735511A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pcl Date: Fri Sep 7 12:23:29 2007 New Revision: 573675 URL: http://svn.apache.org/viewvc?rev=573675&view=rev Log: OPENJPA-355: applying log4j mixup fix to 1.0.x branch. svn merge -c 573653 ../../trunk Modified: openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log4JLogFactory.java Modified: openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log4JLogFactory.java URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log4JLogFactory.java?rev=573675&r1=573674&r2=573675&view=diff ============================================================================== --- openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log4JLogFactory.java (original) +++ openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/Log4JLogFactory.java Fri Sep 7 12:23:29 2007 @@ -49,23 +49,23 @@ } public boolean isTraceEnabled() { - return _log.getEffectiveLevel().toInt() >= Level.DEBUG_INT; + return _log.isEnabledFor(Level.DEBUG); } public boolean isInfoEnabled() { - return _log.getEffectiveLevel().toInt() >= Level.INFO_INT; + return _log.isEnabledFor(Level.INFO); } public boolean isWarnEnabled() { - return _log.getEffectiveLevel().toInt() >= Level.WARN_INT; + return _log.isEnabledFor(Level.WARN); } public boolean isErrorEnabled() { - return _log.getEffectiveLevel().toInt() >= Level.ERROR_INT; + return _log.isEnabledFor(Level.ERROR); } public boolean isFatalEnabled() { - return _log.getEffectiveLevel().toInt() >= Level.FATAL_INT; + return _log.isEnabledFor(Level.FATAL); } public void trace(Object o) { From commits-return-2357-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Fri Sep 07 19:27:36 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 38408 invoked from network); 7 Sep 2007 19:27:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Sep 2007 19:27:36 -0000 Received: (qmail 86719 invoked by uid 500); 7 Sep 2007 19:27:30 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 86660 invoked by uid 500); 7 Sep 2007 19:27:30 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 86650 invoked by uid 99); 7 Sep 2007 19:27:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Sep 2007 12:27:30 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Sep 2007 19:27:35 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 13FFE1A9832; Fri, 7 Sep 2007 12:27:15 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r573676 - in /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql: DB2Dictionary.java DBDictionary.java LogicalUnion.java Select.java SelectImpl.java Date: Fri, 07 Sep 2007 19:27:14 -0000 To: commits@openjpa.apache.org From: pcl@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070907192715.13FFE1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pcl Date: Fri Sep 7 12:27:13 2007 New Revision: 573676 URL: http://svn.apache.org/viewvc?rev=573676&view=rev Log: OPENJPA-356 Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/LogicalUnion.java openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/Select.java openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?rev=573676&r1=573675&r2=573676&view=diff ============================================================================== --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java (original) +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java Fri Sep 7 12:27:13 2007 @@ -154,6 +154,33 @@ append(" ROWS ONLY"); } + protected void appendSelect(SQLBuffer selectSQL, Object alias, Select sel, + int idx) { + // if this is a literal value, add a cast... + Object val = sel.getSelects().get(idx); + if (val instanceof Lit) + selectSQL.append("CAST("); + + // ... and add the select per super's behavior... + super.appendSelect(selectSQL, alias, sel, idx); + + // ... and finish the cast + if (val instanceof Lit) { + Class c = ((Lit) val).getType(); + int javaTypeCode = JavaTypes.getTypeCode(c); + int jdbcTypeCode = getJDBCType(javaTypeCode, false); + String typeName = getTypeName(jdbcTypeCode); + selectSQL.append(" AS " + typeName); + + // if the literal is a string, use the default char col size + // in the cast statement. + if (String.class.equals(c)) + selectSQL.append("(" + characterColumnSize + ")"); + + selectSQL.append(")"); + } + } + public String[] getCreateSequenceSQL(Sequence seq) { String[] sql = super.getCreateSequenceSQL(seq); if (seq.getAllocate() > 1) @@ -646,7 +673,9 @@ public String addCastAsType(String func, Val val) { String fstring = null; String type = getTypeName(getJDBCType(JavaTypes.getTypeCode(val - .getType()), false)); + .getType()), false)); + if (String.class.equals(val.getType())) + type = type + "(" + characterColumnSize + ")"; fstring = "CAST(? AS " + type + ")"; return fstring; } @@ -731,7 +760,10 @@ String sqlString = buf.getSQL(false); if (sqlString.endsWith("?")) { // case "(?" - convert to "CAST(? AS type" - String str = "CAST(? AS " + getTypeName(type) + ")"; + String typeName = getTypeName(type); + if (String.class.equals(val.getType())) + typeName = typeName + "(" + characterColumnSize + ")"; + String str = "CAST(? AS " + typeName + ")"; buf.replaceSqlString(sqlString.length() - 1, sqlString.length(), str); } Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=573676&r1=573675&r2=573676&view=diff ============================================================================== --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java (original) +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java Fri Sep 7 12:27:13 2007 @@ -2272,16 +2272,28 @@ aliases = sel.getSelectAliases(); Object alias; - for (Iterator itr = aliases.iterator(); itr.hasNext();) { - alias = itr.next(); - if (alias instanceof SQLBuffer) - selectSQL.append((SQLBuffer) alias); - else - selectSQL.append(alias.toString()); - if (itr.hasNext()) + for (int i = 0; i < aliases.size(); i++) { + alias = aliases.get(i); + appendSelect(selectSQL, alias, sel, i); + if (i < aliases.size() - 1) selectSQL.append(", "); } return selectSQL; + } + + /** + * Append elem to selectSQL. + * @param selectSQL The SQLBuffer to append to. + * @param alias A {@link SQLBuffer} or a {@link String} to append. + * + * @since 1.1.0 + */ + protected void appendSelect(SQLBuffer selectSQL, Object elem, Select sel, + int idx) { + if (elem instanceof SQLBuffer) + selectSQL.append((SQLBuffer) elem); + else + selectSQL.append(elem.toString()); } /** Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/LogicalUnion.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/LogicalUnion.java?rev=573676&r1=573675&r2=573676&view=diff ============================================================================== --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/LogicalUnion.java (original) +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/LogicalUnion.java Fri Sep 7 12:27:13 2007 @@ -447,6 +447,10 @@ return sel.getTableAliases(); } + public List getSelects() { + return sel.getSelects(); + } + public List getSelectAliases() { return sel.getSelectAliases(); } Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/Select.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/Select.java?rev=573676&r1=573675&r2=573676&view=diff ============================================================================== --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/Select.java (original) +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/Select.java Fri Sep 7 12:27:13 2007 @@ -150,6 +150,14 @@ public Collection getTableAliases(); /** + * Return the actual {@link Val}s and {@link Column}s that were + * selected, in the order that they were selected. + * + * @since 1.1.0 + */ + public List getSelects(); + + /** * Return the aliases of all selected columns and all selected buffers, * in the order they were selected. Each alias may be either a string * or a {@link SQLBuffer}. Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java?rev=573676&r1=573675&r2=573676&view=diff ============================================================================== --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java (original) +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java Fri Sep 7 12:27:13 2007 @@ -505,6 +505,10 @@ return (_tables == null) ? Collections.EMPTY_SET : _tables.values(); } + public List getSelects() { + return Collections.unmodifiableList(_selects); + } + public List getSelectAliases() { return _selects.getAliases(false, _outer != null); } From commits-return-2358-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Fri Sep 07 23:08:29 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 22555 invoked from network); 7 Sep 2007 23:08:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Sep 2007 23:08:28 -0000 Received: (qmail 96678 invoked by uid 500); 7 Sep 2007 23:08:23 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 96665 invoked by uid 500); 7 Sep 2007 23:08:23 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 96656 invoked by uid 99); 7 Sep 2007 23:08:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Sep 2007 16:08:22 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Sep 2007 23:09:49 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2760C1A9832; Fri, 7 Sep 2007 16:08:04 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r573750 - in /openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-kernel/src/main/java/org/apache/openjpa/meta/ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ Date: Fri, 07 Sep 2007 23:08:03 -0000 To: commits@openjpa.apache.org From: ppoddar@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070907230804.2760C1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ppoddar Date: Fri Sep 7 16:08:02 2007 New Revision: 573750 URL: http://svn.apache.org/viewvc?rev=573750&view=rev Log: Fix for FetchGroup inclusion and recursion depth calculation. Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FetchGroup.java openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java?rev=573750&r1=573749&r2=573750&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java (original) +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java Fri Sep 7 16:08:02 2007 @@ -604,6 +604,8 @@ int cur; for (int i = 0; max != FetchGroup.DEPTH_INFINITE && i < groups.length; i++) { + // ignore custom groups that are inactive in this configuration + if (!this.hasFetchGroup(groups[i])) continue; cur = meta.getFetchGroup(groups[i]).getRecursionDepth(fm); if (cur == FetchGroup.DEPTH_INFINITE || cur > max) max = cur; @@ -625,7 +627,7 @@ return avail; return Math.min(max, avail); } - + /** * Return the relation type of the given field. */ Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FetchGroup.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FetchGroup.java?rev=573750&r1=573749&r2=573750&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FetchGroup.java (original) +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FetchGroup.java Fri Sep 7 16:08:02 2007 @@ -21,9 +21,11 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.ObjectUtils; @@ -74,6 +76,7 @@ private final ClassMetaData _meta; private final boolean _readOnly; private List _includes; + private Set _containedBy; private Map _depths; private Boolean _postLoad; @@ -171,6 +174,32 @@ } } return false; + } + + /** + * Sets this receiver as one of the included fetch groups of the given + * parent. + * The parent fecth grop must include this receiver before this call. + * + * @see #includes(String, boolean) + * @see #addDeclaredInclude(String) + */ + public boolean setContainedBy(FetchGroup parent) { + parent.addDeclaredInclude(this.getName()); + if (_containedBy==null) + _containedBy = new HashSet(); + return _containedBy.add(parent.getName()); + } + + /** + * Gets the name of the fetch groups in which this receiver has been + * included. + * + * @see #setContainedBy(FetchGroup) + */ + public String[] getContainedBy() { + return (_containedBy == null) ? new String[0] + : (String[]) _containedBy.toArray(new String[_containedBy.size()]); } /** Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java?rev=573750&r1=573749&r2=573750&view=diff ============================================================================== --- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java (original) +++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java Fri Sep 7 16:08:02 2007 @@ -875,6 +875,14 @@ /** * Create fetch groups. + * If FetchGroup A includes FetchGroup B, then a bi-link is set between + * A and B. Both A and B must be declared in the same Class. + *
+ * Call {@link #parseFetchAttribute(ClassMetaData, + * org.apache.openjpa.meta.FetchGroup, FetchAttribute) only after the + * bi-links have been established, because a field f will not only add the + * fetch group A which explictly includes f to its custom fetch groups but + * also will also add any fetch group B that includes A. */ private void parseFetchGroups(ClassMetaData meta, FetchGroup... groups) { org.apache.openjpa.meta.FetchGroup fg; @@ -885,12 +893,25 @@ fg = meta.addDeclaredFetchGroup(group.name()); if (group.postLoad()) fg.setPostLoad(true); - for (String s : group.fetchGroups()) + for (String s : group.fetchGroups()) { fg.addDeclaredInclude(s); + } + } + + for (FetchGroup group:groups) { + fg = meta.getFetchGroup(group.name()); + String[] includedFetchGropNames = fg.getDeclaredIncludes(); + for (String includedFectchGroupName:includedFetchGropNames) + meta.getFetchGroup(includedFectchGroupName).setContainedBy(fg); + } + + for (FetchGroup group : groups) { + fg = meta.getFetchGroup(group.name()); for (FetchAttribute attr : group.attributes()) parseFetchAttribute(meta, fg, attr); } } + /** * Set a field's fetch group. @@ -904,6 +925,9 @@ meta, attr.name())); field.setInFetchGroup(fg.getName(), true); + String[] parentFetchGroups = fg.getContainedBy(); + for (String parentFetchGroup:parentFetchGroups) + field.setInFetchGroup(parentFetchGroup, true); if (attr.recursionDepth() != Integer.MIN_VALUE) fg.setRecursionDepth(field, attr.recursionDepth()); } From commits-return-2359-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Sun Sep 09 21:12:02 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 49829 invoked from network); 9 Sep 2007 21:12:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Sep 2007 21:12:02 -0000 Received: (qmail 74482 invoked by uid 500); 9 Sep 2007 21:11:55 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 74472 invoked by uid 500); 9 Sep 2007 21:11:55 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 74462 invoked by uid 99); 9 Sep 2007 21:11:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Sep 2007 14:11:55 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Sep 2007 21:12:01 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3A4F21A9832; Sun, 9 Sep 2007 14:11:41 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r574077 - /openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java Date: Sun, 09 Sep 2007 21:11:40 -0000 To: commits@openjpa.apache.org From: ssegu@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070909211141.3A4F21A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ssegu Date: Sun Sep 9 14:11:40 2007 New Revision: 574077 URL: http://svn.apache.org/viewvc?rev=574077&view=rev Log: OPENJPA-363 Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java?rev=574077&r1=574076&r2=574077&view=diff ============================================================================== --- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java (original) +++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java Sun Sep 9 14:11:40 2007 @@ -246,7 +246,9 @@ if (loader == THREAD_LOADER) loader = (ClassLoader) AccessController.doPrivileged( J2DoPrivHelper.getContextClassLoaderAction()); - + + if (loader == null) // skip + continue; try { rsrcs = (Enumeration) AccessController.doPrivileged( From commits-return-2360-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Mon Sep 10 06:12:03 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 85173 invoked from network); 10 Sep 2007 06:12:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Sep 2007 06:12:03 -0000 Received: (qmail 57676 invoked by uid 500); 10 Sep 2007 06:11:57 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 57622 invoked by uid 500); 10 Sep 2007 06:11:56 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 57613 invoked by uid 99); 10 Sep 2007 06:11:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Sep 2007 23:11:56 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Sep 2007 06:11:53 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 27BA61A9832; Sun, 9 Sep 2007 23:11:33 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r574143 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ openjpa-jdbc/src/main/resources/or... Date: Mon, 10 Sep 2007 06:11:30 -0000 To: commits@openjpa.apache.org From: pcl@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070910061133.27BA61A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pcl Date: Sun Sep 9 23:11:29 2007 New Revision: 574143 URL: http://svn.apache.org/viewvc?rev=574143&view=rev Log: OPENJPA-130. Committing Ignacio's patch, with a few whitespace and method name tweaks. Added: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/LobFieldStrategy.java openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/AbstractLobTest.java openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/InputStreamLobEntity.java openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/InputStreamLobTest.java openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/InputStreamWrapper.java openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/LobEntity.java openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/ReaderLobEntity.java openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/ReaderLobTest.java openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/ReaderWrapper.java Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCachePCDataImpl.java openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/JavaTypes.java openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java?rev=574143&r1=574142&r2=574143&view=diff ============================================================================== --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java (original) +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java Sun Sep 9 23:11:29 2007 @@ -40,6 +40,7 @@ import org.apache.openjpa.jdbc.meta.strats.FullClassStrategy; import org.apache.openjpa.jdbc.meta.strats.HandlerFieldStrategy; import org.apache.openjpa.jdbc.meta.strats.ImmutableValueHandler; +import org.apache.openjpa.jdbc.meta.strats.LobFieldStrategy; import org.apache.openjpa.jdbc.meta.strats.MaxEmbeddedBlobFieldStrategy; import org.apache.openjpa.jdbc.meta.strats.MaxEmbeddedByteArrayFieldStrategy; import org.apache.openjpa.jdbc.meta.strats.MaxEmbeddedCharArrayFieldStrategy; @@ -866,6 +867,9 @@ break; return handlerMapStrategy(field, khandler, vhandler, krel, vrel, installHandlers); + case JavaTypes.INPUT_STREAM: + case JavaTypes.INPUT_READER: + return new LobFieldStrategy(); } return null; } Added: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/LobFieldStrategy.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/LobFieldStrategy.java?rev=574143&view=auto ============================================================================== --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/LobFieldStrategy.java (added) +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/LobFieldStrategy.java Sun Sep 9 23:11:29 2007 @@ -0,0 +1,194 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.jdbc.meta.strats; + +import java.io.InputStream; +import java.io.Reader; +import java.sql.SQLException; +import java.sql.Types; + +import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration; +import org.apache.openjpa.jdbc.kernel.JDBCStore; +import org.apache.openjpa.jdbc.meta.FieldMapping; +import org.apache.openjpa.jdbc.meta.ValueMappingInfo; +import org.apache.openjpa.jdbc.schema.Column; +import org.apache.openjpa.jdbc.sql.Result; +import org.apache.openjpa.jdbc.sql.Row; +import org.apache.openjpa.jdbc.sql.RowManager; +import org.apache.openjpa.jdbc.sql.Select; +import org.apache.openjpa.kernel.OpenJPAStateManager; + +/** + * Direct mapping from a stream value to a column. + * + * @author Ignacio Andreu + * @since 1.1.0 + */ +public class LobFieldStrategy extends AbstractFieldStrategy { + + private int fieldType; + + public void map(boolean adapt) { + assertNotMappedBy(); + field.mapJoin(adapt, false); + field.getKeyMapping().getValueInfo().assertNoSchemaComponents + (field.getKey(), !adapt); + field.getElementMapping().getValueInfo().assertNoSchemaComponents + (field.getElement(), !adapt); + field.setStream(true); + ValueMappingInfo vinfo = field.getValueInfo(); + vinfo.assertNoJoin(field, true); + vinfo.assertNoForeignKey(field, !adapt); + Column tmpCol = new Column(); + tmpCol.setName(field.getName()); + tmpCol.setJavaType(field.getTypeCode()); + tmpCol.setType(fieldType); + tmpCol.setSize(-1); + + Column[] cols = vinfo.getColumns(field, field.getName(), + new Column[]{ tmpCol }, field.getTable(), adapt); + + field.setColumns(cols); + field.setColumnIO(vinfo.getColumnIO()); + field.mapConstraints(field.getName(), adapt); + field.mapPrimaryKey(adapt); + } + + public Boolean isCustomInsert(OpenJPAStateManager sm, JDBCStore store) { + return null; + } + + public void insert(OpenJPAStateManager sm, JDBCStore store, RowManager rm) + throws SQLException { + Object ob = toDataStoreValue(sm.fetchObjectField + (field.getIndex()), store); + Row row = field.getRow(sm, store, rm, Row.ACTION_INSERT); + if (field.getColumnIO().isInsertable(0, ob == null)) { + if (ob != null) { + if (isBlob()) { + store.getDBDictionary().insertBlobForStreamingLoad + (row, field.getColumns()[0]); + } else { + store.getDBDictionary().insertClobForStreamingLoad + (row, field.getColumns()[0]); + } + } else { + Column col = field.getColumns()[0]; + col.setType(Types.OTHER); + row.setNull(col); + } + } + } + + public void customInsert(OpenJPAStateManager sm, JDBCStore store) + throws SQLException { + Object ob = toDataStoreValue(sm.fetchObjectField + (field.getIndex()), store); + if (field.getColumnIO().isInsertable(0, ob == null)) { + if (ob != null) { + Select sel = createSelect(sm, store); + if (isBlob()) { + store.getDBDictionary().updateBlob + (sel, store, (InputStream)ob); + } else { + store.getDBDictionary().updateClob + (sel, store, (Reader)ob); + } + } + } + } + + public void update(OpenJPAStateManager sm, JDBCStore store, RowManager rm) + throws SQLException { + Object ob = toDataStoreValue(sm.fetchObjectField + (field.getIndex()), store); + if (field.getColumnIO().isUpdatable(0, ob == null)) { + if (ob != null) { + Select sel = createSelect(sm, store); + if (isBlob()) { + store.getDBDictionary().updateBlob + (sel, store, (InputStream)ob); + } else { + store.getDBDictionary().updateClob + (sel, store, (Reader)ob); + } + } else { + Row row = field.getRow(sm, store, rm, Row.ACTION_UPDATE); + Column col = field.getColumns()[0]; + col.setType(Types.OTHER); + row.setNull(col); + } + } + } + + public int supportsSelect(Select sel, int type, OpenJPAStateManager sm, + JDBCStore store, JDBCFetchConfiguration fetch) { + if (type == Select.TYPE_JOINLESS && sel.isSelected(field.getTable())) + return 1; + return 0; + } + + public int select(Select sel, OpenJPAStateManager sm, JDBCStore store, + JDBCFetchConfiguration fetch, int eagerMode) { + sel.select(field.getColumns()[0], field.join(sel)); + return 1; + } + + public void load(OpenJPAStateManager sm, JDBCStore store, + JDBCFetchConfiguration fetch, Result res) throws SQLException { + Column col = field.getColumns()[0]; + if (res.contains(col)) { + if (isBlob()) { + sm.storeObject(field.getIndex(), res.getBinaryStream(col)); + } else { + sm.storeObject(field.getIndex(), res.getCharacterStream(col)); + } + } + } + + protected void assertNotMappedBy() { + if (field != null && field.getMappedBy() != null) + throw new UnsupportedOperationException(); + } + + public void setFieldMapping(FieldMapping owner) { + if (owner.getType().isAssignableFrom(InputStream.class)) { + fieldType = Types.BLOB; + } else if (owner.getType().isAssignableFrom(Reader.class)) { + fieldType = Types.CLOB; + } + field = owner; + } + + private boolean isBlob() { + if (fieldType == Types.BLOB) + return true; + return false; + } + + private Select createSelect(OpenJPAStateManager sm, JDBCStore store) { + Select sel = store.getSQLFactory().newSelect(); + sel.select(field.getColumns()[0]); + sel.selectPrimaryKey(field.getDefiningMapping()); + sel.wherePrimaryKey + (sm.getObjectId(), field.getDefiningMapping(), store); + sel.setLob(true); + return sel; + } +} Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=574143&r1=574142&r2=574143&view=diff ============================================================================== --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java (original) +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java Sun Sep 9 23:11:29 2007 @@ -20,9 +20,11 @@ import java.io.BufferedReader; import java.io.ByteArrayInputStream; +import java.io.CharArrayReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.OutputStream; import java.io.Reader; import java.io.StringReader; import java.io.Writer; @@ -96,6 +98,7 @@ import org.apache.openjpa.lib.util.Localizer.Message; import org.apache.openjpa.meta.JavaTypes; import org.apache.openjpa.util.GeneralException; +import org.apache.openjpa.util.InternalException; import org.apache.openjpa.util.OpenJPAException; import org.apache.openjpa.util.ReferentialIntegrityException; import org.apache.openjpa.util.Serialization; @@ -124,6 +127,9 @@ public static final String CONS_NAME_BEFORE = "before"; public static final String CONS_NAME_MID = "mid"; public static final String CONS_NAME_AFTER = "after"; + + public int blobBufferSize = 50; + public int clobBufferSize = 50; protected static final int RANGE_POST_SELECT = 0; protected static final int RANGE_PRE_DISTINCT = 1; @@ -3920,6 +3926,109 @@ return column.toString(); } + public void insertBlobForStreamingLoad(Row row, Column col) + throws SQLException { + row.setBinaryStream(col, + new ByteArrayInputStream(new byte[0]), 0); + } + + public void insertClobForStreamingLoad(Row row, Column col) + throws SQLException { + row.setCharacterStream(col, + new CharArrayReader(new char[0]), 0); + } + + public void updateBlob(Select sel, JDBCStore store, InputStream is) + throws SQLException { + SQLBuffer sql = sel.toSelect(true, store.getFetchConfiguration()); + ResultSet res = null; + Connection conn = store.getConnection(); + PreparedStatement stmnt = null; + try { + stmnt = sql.prepareStatement(conn, store.getFetchConfiguration(), + ResultSet.TYPE_SCROLL_SENSITIVE, + ResultSet.CONCUR_UPDATABLE); + res = stmnt.executeQuery(); + if (!res.next()) { + throw new InternalException(_loc.get("stream-exception")); + } + Blob blob = res.getBlob(1); + OutputStream os = blob.setBinaryStream(1); + copy(is, os); + os.close(); + res.updateBlob(1, blob); + res.updateRow(); + + } catch (IOException ioe) { + throw new StoreException(ioe); + } finally { + if (res != null) + try { res.close (); } catch (SQLException e) {} + if (stmnt != null) + try { stmnt.close (); } catch (SQLException e) {} + if (conn != null) + try { conn.close (); } catch (SQLException e) {} + } + } + + public void updateClob(Select sel, JDBCStore store, Reader reader) + throws SQLException { + SQLBuffer sql = sel.toSelect(true, store.getFetchConfiguration()); + ResultSet res = null; + Connection conn = store.getConnection(); + PreparedStatement stmnt = null; + try { + stmnt = sql.prepareStatement(conn, store.getFetchConfiguration(), + ResultSet.TYPE_SCROLL_SENSITIVE, + ResultSet.CONCUR_UPDATABLE); + res = stmnt.executeQuery(); + if (!res.next()) { + throw new InternalException(_loc.get("stream-exception")); + } + Clob clob = res.getClob(1); + Writer writer = clob.setCharacterStream(1); + copy(reader, writer); + writer.close(); + res.updateClob(1, clob); + res.updateRow(); + + } catch (IOException ioe) { + throw new StoreException(ioe); + } finally { + if (res != null) + try { res.close (); } catch (SQLException e) {} + if (stmnt != null) + try { stmnt.close (); } catch (SQLException e) {} + if (conn != null) + try { conn.close (); } catch (SQLException e) {} + } + } + + protected long copy(InputStream in, OutputStream out) throws IOException { + byte[] copyBuffer = new byte[blobBufferSize]; + long bytesCopied = 0; + int read = -1; + + while ((read = in.read(copyBuffer, 0, copyBuffer.length)) != -1) { + out.write(copyBuffer, 0, read); + bytesCopied += read; + } + return bytesCopied; + } + + protected long copy(Reader reader, Writer writer) throws IOException { + char[] copyBuffer = new char[clobBufferSize]; + long bytesCopied = 0; + int read = -1; + + while ((read = reader.read(copyBuffer, 0, copyBuffer.length)) != -1) { + writer.write(copyBuffer, 0, read); + bytesCopied += read; + } + + return bytesCopied; + } + /** * Attach CAST to the current function if necessary * @@ -3930,5 +4039,4 @@ public String getCastFunction(Val val, String func) { return func; } - } Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java?rev=574143&r1=574142&r2=574143&view=diff ============================================================================== --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java (original) +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java Sun Sep 9 23:11:29 2007 @@ -49,6 +49,7 @@ import org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement; import org.apache.openjpa.lib.util.Localizer; import org.apache.openjpa.util.StoreException; + import serp.util.Numbers; /** @@ -1096,5 +1097,15 @@ append(",'/*/"); val.appendTo(buf); buf.append("')"); + } + + public void insertBlobForStreamingLoad(Row row, Column col) + throws SQLException { + row.setNull(col); + } + + public void insertClobForStreamingLoad(Row row, Column col) + throws SQLException { + row.setNull(col); } } Modified: openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties?rev=574143&r1=574142&r2=574143&view=diff ============================================================================== --- openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties (original) +++ openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties Sun Sep 9 23:11:29 2007 @@ -168,4 +168,4 @@ millis-query-timeout: JDBC locking does not support millisecond-granularity \ timeouts. Use timeouts that are multiples of 1000 for even second values. db-not-supported: The database product "{0}", version "{1}" is not officially supported. - \ No newline at end of file +stream-exception: Unexpected error recovering the row to stream the LOB. Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCachePCDataImpl.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCachePCDataImpl.java?rev=574143&r1=574142&r2=574143&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCachePCDataImpl.java (original) +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCachePCDataImpl.java Sun Sep 9 23:11:29 2007 @@ -121,7 +121,7 @@ protected Object toData(FieldMetaData fmd, Object val, StoreContext ctx) { // avoid caching large result set fields - if (fmd.isLRS()) + if (fmd.isLRS() || fmd.isStream()) return NULL; return super.toData(fmd, val, ctx); } Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java?rev=574143&r1=574142&r2=574143&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java (original) +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java Sun Sep 9 23:11:29 2007 @@ -166,6 +166,7 @@ private String[] _fgs = null; private String _lfg = null; private Boolean _lrs = null; + private Boolean _stream = null; private String _extName = null; private String _factName = null; private String _extString = null; @@ -1027,6 +1028,24 @@ _lrs = (lrs) ? Boolean.TRUE : Boolean.FALSE; } + /** + * Whether this field is backed by a stream. + * + * @since 1.1.0 + */ + public boolean isStream() { + return _stream == Boolean.TRUE && _manage == MANAGE_PERSISTENT; + } + + /** + * Whether this field is backed by a stream. + * + * @since 1.1.0 + */ + public void setStream(boolean stream) { + _stream = (stream) ? Boolean.TRUE : Boolean.FALSE; + } + /** * Whether this field uses intermediate data when loading/storing * information through a {@link OpenJPAStateManager}. Defaults to true. Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/JavaTypes.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/JavaTypes.java?rev=574143&r1=574142&r2=574143&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/JavaTypes.java (original) +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/JavaTypes.java Sun Sep 9 23:11:29 2007 @@ -18,6 +18,8 @@ */ package org.apache.openjpa.meta; +import java.io.InputStream; +import java.io.Reader; import java.io.Serializable; import java.lang.reflect.Array; import java.math.BigDecimal; @@ -79,6 +81,8 @@ public static final int PC_UNTYPED = 27; public static final int CALENDAR = 28; public static final int OID = 29; + public static final int INPUT_STREAM = 30; + public static final int INPUT_READER = 31; private static final Localizer _loc = Localizer.forPackage(JavaTypes.class); @@ -156,9 +160,14 @@ return OBJECT; return PC_UNTYPED; } + if (type.isAssignableFrom(Reader.class)) + return INPUT_READER; + if (type.isAssignableFrom (InputStream.class)) + return INPUT_STREAM; + return OBJECT; } - + /** * Check the given name against the same set of standard packages used * when parsing metadata. Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java?rev=574143&r1=574142&r2=574143&view=diff ============================================================================== --- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java (original) +++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java Sun Sep 9 23:11:29 2007 @@ -436,11 +436,19 @@ _rs.updateBinaryStream(a, in, b); } + public void updateBlob(int a, Blob blob) throws SQLException { + _rs.updateBlob(a, blob); + } + public void updateCharacterStream(int a, Reader reader, int b) throws SQLException { _rs.updateCharacterStream(a, reader, b); } + public void updateClob(int a, Clob clob) throws SQLException { + _rs.updateClob(a, clob); + } + public void updateObject(int a, Object ob, int b) throws SQLException { _rs.updateObject(a, ob, b); } @@ -643,15 +651,7 @@ throw new UnsupportedOperationException(); } - public void updateBlob(int column, Blob blob) throws SQLException { - throw new UnsupportedOperationException(); - } - public void updateBlob(String columnName, Blob blob) throws SQLException { - throw new UnsupportedOperationException(); - } - - public void updateClob(int column, Clob clob) throws SQLException { throw new UnsupportedOperationException(); } Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/AbstractLobTest.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/AbstractLobTest.java?rev=574143&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/AbstractLobTest.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/AbstractLobTest.java Sun Sep 9 23:11:29 2007 @@ -0,0 +1,247 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.openjpa.jdbc.meta.strats; + +import java.io.IOException; +import javax.persistence.EntityManager; +import javax.persistence.Query; + +import org.apache.openjpa.conf.OpenJPAConfiguration; +import org.apache.openjpa.datacache.DataCachePCData; +import org.apache.openjpa.jdbc.conf.JDBCConfiguration; +import org.apache.openjpa.jdbc.sql.DBDictionary; +import org.apache.openjpa.jdbc.sql.MySQLDictionary; +import org.apache.openjpa.jdbc.sql.OracleDictionary; +import org.apache.openjpa.jdbc.sql.SQLServerDictionary; +import org.apache.openjpa.meta.ClassMetaData; +import org.apache.openjpa.persistence.JPAFacadeHelper; +import org.apache.openjpa.persistence.OpenJPAEntityManager; +import org.apache.openjpa.persistence.test.SingleEMFTestCase; + +/** + * This abstract class defines all the tests for LOBS. + * + * @author Ignacio Andreu + * @since 1.1.0 + */ + +public abstract class AbstractLobTest extends SingleEMFTestCase { + + public void setUp() throws Exception { + super.setUp(getLobEntityClass(), CLEAR_TABLES, + "openjpa.DataCache", "true", + "openjpa.RemoteCommitProvider", "sjvm"); + } + + public boolean isDatabaseSupported() { + DBDictionary dict = ((JDBCConfiguration) emf.getConfiguration()) + .getDBDictionaryInstance(); + if (dict instanceof MySQLDictionary || + dict instanceof SQLServerDictionary || + dict instanceof OracleDictionary) { + return true; + } + return false; + } + + public void insert(LobEntity le) { + EntityManager em = emf.createEntityManager(); + em.getTransaction().begin(); + em.persist(le); + em.getTransaction().commit(); + em.close(); + } + + public void testInsert() { + if (!isDatabaseSupported()) return; + insert(newLobEntity("oOOOOOo", 1)); + } + + public void testInsertAndSelect() throws IOException { + if (!isDatabaseSupported()) return; + String s = "oooOOOooo"; + insert(newLobEntity(s, 1)); + EntityManager em = emf.createEntityManager(); + em.getTransaction().begin(); + Query query = em.createQuery(getSelectQuery()); + LobEntity entity = (LobEntity) query.getSingleResult(); + assertNotNull(entity.getStream()); + assertEquals(s, getStreamContentAsString(entity.getStream())); + em.getTransaction().commit(); + em.close(); + } + + public void testInsertNull() { + if (!isDatabaseSupported()) return; + insert(newLobEntity(null, 1)); + EntityManager em = emf.createEntityManager(); + em.getTransaction().begin(); + LobEntity le = (LobEntity) em.find(getLobEntityClass(), 1); + assertNull(le.getStream()); + em.getTransaction().commit(); + em.close(); + } + + public void testUpdate() throws IOException { + if (!isDatabaseSupported()) return; + insert(newLobEntity("oOOOOOo", 1)); + EntityManager em = emf.createEntityManager(); + em.getTransaction().begin(); + LobEntity entity = (LobEntity) em.find(getLobEntityClass(), 1); + String string = "iIIIIIi"; + changeStream(entity, string); + em.getTransaction().commit(); + em.close(); + em = emf.createEntityManager(); + em.getTransaction().begin(); + entity = (LobEntity) em.find(getLobEntityClass(), 1); + assertEquals(string, getStreamContentAsString(entity.getStream())); + em.getTransaction().commit(); + em.close(); + } + + public void testDelete() { + if (!isDatabaseSupported()) return; + insert(newLobEntity("oOOOOOo", 1)); + EntityManager em = emf.createEntityManager(); + em.getTransaction().begin(); + LobEntity entity = (LobEntity) em.find(getLobEntityClass(), 1); + em.remove(entity); + em.getTransaction().commit(); + em.close(); + em = emf.createEntityManager(); + em.getTransaction().begin(); + Query q = em.createQuery(getSelectQuery()); + assertEquals(0, q.getResultList().size()); + em.getTransaction().commit(); + em.close(); + } + + public void testLifeCycleInsertFlushModify() { + if (!isDatabaseSupported()) return; + EntityManager em = emf.createEntityManager(); + em.getTransaction().begin(); + LobEntity le = newLobEntity("oOOOOOo", 1); + em.persist(le); + em.flush(); + changeStream(le, "iIIIIIi"); + em.getTransaction().commit(); + em.close(); + } + + public void testLifeCycleLoadFlushModifyFlush() { + if (!isDatabaseSupported()) return; + insert(newLobEntity("oOOOOOo", 1)); + EntityManager em = emf.createEntityManager(); + em.getTransaction().begin(); + LobEntity entity = (LobEntity) em.find(getLobEntityClass(), 1); + em.flush(); + changeStream(entity, "iIIIIIi"); + em.flush(); + em.getTransaction().commit(); + em.close(); + } + + public void testReadingMultipleTimesWithASingleConnection() + throws IOException { + if (!isDatabaseSupported()) return; + insert(newLobEntity("oOOOOOo", 1)); + EntityManager em = emf.createEntityManager(); + em.getTransaction().begin(); + LobEntity le = (LobEntity) em.find(getLobEntityClass(), 1); + String string = "iIIIIIi"; + changeStream(le, string); + em.getTransaction().commit(); + em.close(); + em = emf.createEntityManager(); + em.getTransaction().begin(); + le = (LobEntity) em.find(getLobEntityClass(), 1); + assertNotNull(le.getStream()); + LobEntity entity = newLobEntity("oOOOOOo", 2); + em.persist(entity); + assertEquals(string, getStreamContentAsString(le.getStream())); + em.getTransaction().commit(); + em.close(); + } + + public void testDataCache() { + if (!isDatabaseSupported()) return; + OpenJPAEntityManager em = emf.createEntityManager(); + + em.getTransaction().begin(); + LobEntity le = newLobEntity("oOOOOOo", 1); + em.persist(le); + em.getTransaction().commit(); + OpenJPAConfiguration conf = emf.getConfiguration(); + Object o = em.getObjectId(le); + ClassMetaData meta = JPAFacadeHelper.getMetaData(le); + Object objectId = JPAFacadeHelper.toOpenJPAObjectId(meta, o); + DataCachePCData pcd = + conf.getDataCacheManagerInstance() + .getSystemDataCache().get(objectId); + assertFalse(pcd.isLoaded(meta.getField("stream").getIndex())); + em.close(); + } + + public void testSetResetAndFlush() throws IOException { + if (!isDatabaseSupported()) return; + EntityManager em = emf.createEntityManager(); + em.getTransaction().begin(); + LobEntity le = newLobEntity("oOOOOOo", 1); + em.persist(le); + changeStream(le, "iIIIIIi"); + em.flush(); + em.getTransaction().commit(); + em.close(); + em = emf.createEntityManager(); + em.getTransaction().begin(); + LobEntity entity = (LobEntity) em.find(getLobEntityClass(), 1); + assertEquals("iIIIIIi", getStreamContentAsString(entity.getStream())); + em.getTransaction().commit(); + em.close(); + } + + public void testSetFlushAndReset() throws IOException { + if (!isDatabaseSupported()) return; + EntityManager em = emf.createEntityManager(); + em.getTransaction().begin(); + LobEntity le = newLobEntity("oOOOOOo", 1); + em.persist(le); + em.flush(); + changeStream(le, "iIIIIIi"); + LobEntity entity = (LobEntity) em.find(getLobEntityClass(), 1); + assertEquals("iIIIIIi", getStreamContentAsString(entity.getStream())); + em.getTransaction().commit(); + em.close(); + } + + protected abstract Class getLobEntityClass(); + + protected abstract String getStreamContentAsString(Object o) + throws IOException; + + protected abstract LobEntity newLobEntity(String s, int id); + + protected abstract LobEntity newLobEntityForLoadContent(String s, int id); + + protected abstract String getSelectQuery(); + + protected abstract void changeStream(LobEntity le, String s); +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/InputStreamLobEntity.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/InputStreamLobEntity.java?rev=574143&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/InputStreamLobEntity.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/InputStreamLobEntity.java Sun Sep 9 23:11:29 2007 @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.jdbc.meta.strats; + +import java.io.InputStream; +import javax.persistence.Entity; +import javax.persistence.Id; + +import org.apache.openjpa.persistence.Persistent; + +/** + * An entity with an InputStream. + * + * @author Ignacio Andreu + * @since 1.1.0 + */ + +@Entity +public class InputStreamLobEntity implements LobEntity { + + @Id + private int id; + + @Persistent + private InputStream stream; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Object getStream() { + return stream; + } + + public void setStream(Object o) { + stream = (InputStream) o; + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/InputStreamLobTest.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/InputStreamLobTest.java?rev=574143&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/InputStreamLobTest.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/InputStreamLobTest.java Sun Sep 9 23:11:29 2007 @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.jdbc.meta.strats; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; + +/** + * Defines all the abstract methods from AbstractLobTest to tests the + * the LOB support with an InputStream. + * + * @author Ignacio Andreu + * @since 1.1.0 + */ + +public class InputStreamLobTest extends AbstractLobTest { + + protected LobEntity newLobEntity(String s, int id) { + InputStreamLobEntity isle = new InputStreamLobEntity(); + isle.setId(id); + if (s != null) { + isle.setStream(new ByteArrayInputStream(s.getBytes())); + } else { + isle.setStream(null); + } + return isle; + } + + protected LobEntity newLobEntityForLoadContent(String s, int id) { + InputStreamLobEntity isle = new InputStreamLobEntity(); + isle.setId(id); + isle.setStream(new InputStreamWrapper(s)); + return isle; + } + + protected Class getLobEntityClass() { + return InputStreamLobEntity.class; + } + + protected String getSelectQuery() { + return "SELECT o FROM InputStreamLobEntity o"; + } + + protected String getStreamContentAsString(Object o) throws IOException { + InputStream is = (InputStream) o; + String content = ""; + byte[] bs = new byte[4]; + int read = -1; + do { + read = is.read(bs); + if (read == -1) { + return content; + } + content = content + (new String(bs)).substring(0, read); + } while (true); + } + + protected void changeStream(LobEntity le, String s) { + le.setStream(new ByteArrayInputStream(s.getBytes())); + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/InputStreamWrapper.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/InputStreamWrapper.java?rev=574143&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/InputStreamWrapper.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/InputStreamWrapper.java Sun Sep 9 23:11:29 2007 @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.jdbc.meta.strats; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; + +/** + * This class is used to kwon where the content of the InputStream is load. + * If the content is load out of the flush then throws a + * UnsupportedOperationException + * + * @author Ignacio Andreu + * @since 1.1.0 + */ + +public class InputStreamWrapper extends InputStream { + + private InputStream is; + + public InputStreamWrapper(String s) { + this.is = new ByteArrayInputStream(s.getBytes()); + } + + public int read() throws IOException { + throw new UnsupportedOperationException(); + } + + public int available() throws IOException { + return is.available(); + } + + public void close() throws IOException { + is.close(); + } + + public int read(byte[] b, int off, int len) throws IOException { + StackTraceElement[] ste = Thread.currentThread().getStackTrace(); + for (StackTraceElement element : ste) { + if ("flush".equals(element.getMethodName())) { + return is.read(b, off, len); + } + } + throw new UnsupportedOperationException(); + } + + public int read(byte[] b) throws IOException { + throw new UnsupportedOperationException(); + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/LobEntity.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/LobEntity.java?rev=574143&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/LobEntity.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/LobEntity.java Sun Sep 9 23:11:29 2007 @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.openjpa.jdbc.meta.strats; + +/** + * Defines the methods for the entities + * + * @author Ignacio Andreu + * @since 1.1.0 + */ +public interface LobEntity { + + public void setStream(Object o); + + public void setId(int id); + + public Object getStream(); + + public int getId(); +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/ReaderLobEntity.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/ReaderLobEntity.java?rev=574143&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/ReaderLobEntity.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/ReaderLobEntity.java Sun Sep 9 23:11:29 2007 @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.jdbc.meta.strats; + +import java.io.Reader; +import javax.persistence.Entity; +import javax.persistence.Id; + +import org.apache.openjpa.persistence.Persistent; + +/** + * An entity with a Reader field. + * + * @author Ignacio Andreu + * @since 1.1.0 + */ + +@Entity +public class ReaderLobEntity implements LobEntity { + + @Id + int id; + + @Persistent + Reader stream; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Object getStream() { + return stream; + } + + public void setStream(Object o) { + this.stream = (Reader) o; + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/ReaderLobTest.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/ReaderLobTest.java?rev=574143&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/ReaderLobTest.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/ReaderLobTest.java Sun Sep 9 23:11:29 2007 @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.jdbc.meta.strats; + +import java.io.CharArrayReader; +import java.io.IOException; +import java.io.Reader; + +/** + * Defines all the abstract methods from AbstractLobTest to tests the + * the LOB support with a Reader. + * + * @author Ignacio Andreu + * @since 1.1.0 + */ + +public class ReaderLobTest extends AbstractLobTest { + + protected LobEntity newLobEntity(String s, int id) { + ReaderLobEntity rle = new ReaderLobEntity(); + rle.setId(id); + if (s != null) { + rle.setStream(new CharArrayReader(s.toCharArray())); + } else { + rle.setStream(null); + } + return rle; + } + + protected LobEntity newLobEntityForLoadContent(String s, int id) { + ReaderLobEntity rle = new ReaderLobEntity(); + rle.setId(id); + rle.setStream(new ReaderWrapper(s)); + return rle; + } + + protected Class getLobEntityClass() { + return ReaderLobEntity.class; + } + + protected String getSelectQuery() { + return "SELECT o FROM ReaderLobEntity o"; + } + + protected String getStreamContentAsString(Object o) throws IOException { + Reader r = (Reader) o; + String content = ""; + char[] cs = new char[4]; + int read = -1; + do { + read = r.read(cs); + if (read == -1) { + return content; + } + content = content + (new String(cs)).substring(0, read); + } while (true); + } + + protected void changeStream(LobEntity le, String s) { + le.setStream(new CharArrayReader(s.toCharArray())); + } +} Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/ReaderWrapper.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/ReaderWrapper.java?rev=574143&view=auto ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/ReaderWrapper.java (added) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/ReaderWrapper.java Sun Sep 9 23:11:29 2007 @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.jdbc.meta.strats; + +import java.io.CharArrayReader; +import java.io.IOException; +import java.io.Reader; + +/** + * This class is used to kwon where the content of the Reader is load. + * If the content is load out of the flush then throws a + * UnsupportedOperationException + * + * @author Ignacio Andreu + * @since 1.1.0 + */ + +public class ReaderWrapper extends Reader { + + private Reader reader; + + public ReaderWrapper(String s) { + this.reader = new CharArrayReader(s.toCharArray()); + } + + public void close() throws IOException { + reader.close(); + } + + public int read(char[] cbuf, int off, int len) throws IOException { + StackTraceElement[] ste = Thread.currentThread().getStackTrace(); + for (StackTraceElement element : ste) { + if ("flush".equals(element.getMethodName())) { + return reader.read(cbuf, off, len); + } + } + throw new UnsupportedOperationException(); + } +} From commits-return-2361-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Mon Sep 10 15:53:45 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 79220 invoked from network); 10 Sep 2007 15:53:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Sep 2007 15:53:45 -0000 Received: (qmail 80204 invoked by uid 500); 10 Sep 2007 15:53:38 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 80189 invoked by uid 500); 10 Sep 2007 15:53:38 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 80178 invoked by uid 99); 10 Sep 2007 15:53:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Sep 2007 08:53:38 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Sep 2007 15:55:15 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 242521A9832; Mon, 10 Sep 2007 08:53:22 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r574285 - /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java Date: Mon, 10 Sep 2007 15:53:21 -0000 To: commits@openjpa.apache.org From: pcl@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070910155322.242521A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pcl Date: Mon Sep 10 08:53:21 2007 New Revision: 574285 URL: http://svn.apache.org/viewvc?rev=574285&view=rev Log: Fixing incorrect return value. Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=574285&r1=574284&r2=574285&view=diff ============================================================================== --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java (original) +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java Mon Sep 10 08:53:21 2007 @@ -3213,7 +3213,7 @@ * @since 1.1.0 */ protected boolean supportsDeferredUniqueConstraints() { - return supportsUniqueConstraints; + return supportsDeferredConstraints; } ///////////////////// From commits-return-2362-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Mon Sep 10 16:02:07 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 93675 invoked from network); 10 Sep 2007 16:02:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Sep 2007 16:02:05 -0000 Received: (qmail 99836 invoked by uid 500); 10 Sep 2007 16:01:59 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 99818 invoked by uid 500); 10 Sep 2007 16:01:59 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 99809 invoked by uid 99); 10 Sep 2007 16:01:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Sep 2007 09:01:59 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Sep 2007 16:03:35 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4E3DF1A9838; Mon, 10 Sep 2007 09:01:42 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r574289 - in /openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/meta/FetchGroup.java openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java Date: Mon, 10 Sep 2007 16:01:41 -0000 To: commits@openjpa.apache.org From: ppoddar@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070910160142.4E3DF1A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ppoddar Date: Mon Sep 10 09:01:40 2007 New Revision: 574289 URL: http://svn.apache.org/viewvc?rev=574289&view=rev Log: OPENJPA-357, OPENJPA-358: Adding @since tag/comments to new additions to FetchGroup inclusion Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FetchGroup.java openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FetchGroup.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FetchGroup.java?rev=574289&r1=574288&r2=574289&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FetchGroup.java (original) +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FetchGroup.java Mon Sep 10 09:01:40 2007 @@ -20,6 +20,7 @@ import java.io.Serializable; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -108,6 +109,9 @@ if (fg._includes != null) for (Iterator itr = fg._includes.iterator(); itr.hasNext();) addDeclaredInclude((String) itr.next()); + if (fg._containedBy != null) + this._containedBy = new HashSet(fg._containedBy); + if (fg._depths != null) { Map.Entry entry; for (Iterator itr = fg._depths.entrySet().iterator(); @@ -155,7 +159,7 @@ if (_includes != null) { if (_includes.contains(fgName)) return true; - if (recurse) { + if (recurse && _meta!=null) { FetchGroup fg; for (Iterator i = _includes.iterator(); i.hasNext();) { fg = _meta.getFetchGroup((String) i.next()); @@ -177,14 +181,18 @@ } /** - * Sets this receiver as one of the included fetch groups of the given + * Adds this receiver as one of the included fetch groups of the given * parent. - * The parent fecth grop must include this receiver before this call. + * The parent fecth group will include this receiver as a side-effect of + * this call. * * @see #includes(String, boolean) * @see #addDeclaredInclude(String) + * + * @return true if given parent is a new addition. false othrwise. + * @since 1.1.1 */ - public boolean setContainedBy(FetchGroup parent) { + public boolean addContainedBy(FetchGroup parent) { parent.addDeclaredInclude(this.getName()); if (_containedBy==null) _containedBy = new HashSet(); @@ -195,11 +203,12 @@ * Gets the name of the fetch groups in which this receiver has been * included. * - * @see #setContainedBy(FetchGroup) + * @see #addContainedBy(FetchGroup) + * @since 1.1.1 */ - public String[] getContainedBy() { - return (_containedBy == null) ? new String[0] - : (String[]) _containedBy.toArray(new String[_containedBy.size()]); + public Set getContainedBy() { + return (_containedBy == null) ? Collections.EMPTY_SET : + Collections.unmodifiableSet(_containedBy); } /** Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java?rev=574289&r1=574288&r2=574289&view=diff ============================================================================== --- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java (original) +++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java Mon Sep 10 09:01:40 2007 @@ -902,7 +902,7 @@ fg = meta.getFetchGroup(group.name()); String[] includedFetchGropNames = fg.getDeclaredIncludes(); for (String includedFectchGroupName:includedFetchGropNames) - meta.getFetchGroup(includedFectchGroupName).setContainedBy(fg); + meta.getFetchGroup(includedFectchGroupName).addContainedBy(fg); } for (FetchGroup group : groups) { @@ -925,9 +925,9 @@ meta, attr.name())); field.setInFetchGroup(fg.getName(), true); - String[] parentFetchGroups = fg.getContainedBy(); - for (String parentFetchGroup:parentFetchGroups) - field.setInFetchGroup(parentFetchGroup, true); + Set parentFetchGroups = fg.getContainedBy(); + for (Object parentFetchGroup:parentFetchGroups) + field.setInFetchGroup(parentFetchGroup.toString(), true); if (attr.recursionDepth() != Integer.MIN_VALUE) fg.setRecursionDepth(field, attr.recursionDepth()); } From commits-return-2363-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Mon Sep 10 16:20:41 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 17234 invoked from network); 10 Sep 2007 16:20:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Sep 2007 16:20:41 -0000 Received: (qmail 35628 invoked by uid 500); 10 Sep 2007 16:20:34 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 35613 invoked by uid 500); 10 Sep 2007 16:20:34 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 35604 invoked by uid 99); 10 Sep 2007 16:20:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Sep 2007 09:20:34 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Sep 2007 16:20:40 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6F5181A9832; Mon, 10 Sep 2007 09:20:17 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r574293 - in /openjpa/trunk/openjpa-persistence/src/main: java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java resources/org/apache/openjpa/persistence/localizer.properties Date: Mon, 10 Sep 2007 16:20:17 -0000 To: commits@openjpa.apache.org From: ppoddar@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070910162018.6F5181A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ppoddar Date: Mon Sep 10 09:20:08 2007 New Revision: 574293 URL: http://svn.apache.org/viewvc?rev=574293&view=rev Log: OPENJPA-357, OPENJPA-358: Checking for user error of wrong fetch group inclusion Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java?rev=574293&r1=574292&r2=574293&view=diff ============================================================================== --- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java (original) +++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java Mon Sep 10 09:20:08 2007 @@ -109,6 +109,8 @@ import org.apache.openjpa.util.InternalException; import org.apache.openjpa.util.MetaDataException; import org.apache.openjpa.util.UnsupportedException; +import org.apache.openjpa.util.UserException; + import serp.util.Numbers; import serp.util.Strings; @@ -897,12 +899,20 @@ fg.addDeclaredInclude(s); } } - + // Add the parent-child style bi-links between fetch groups in a + // separate pass. for (FetchGroup group:groups) { fg = meta.getFetchGroup(group.name()); String[] includedFetchGropNames = fg.getDeclaredIncludes(); - for (String includedFectchGroupName:includedFetchGropNames) - meta.getFetchGroup(includedFectchGroupName).addContainedBy(fg); + for (String includedFectchGroupName:includedFetchGropNames) { + org.apache.openjpa.meta.FetchGroup child = + meta.getFetchGroup(includedFectchGroupName); + if (child == null) + throw new UserException(_loc.get("missing-included-fg", + meta.getDescribedType().getName(), fg.getName(), + includedFectchGroupName)); + child.addContainedBy(fg); + } } for (FetchGroup group : groups) { Modified: openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties?rev=574293&r1=574292&r2=574293&view=diff ============================================================================== --- openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties (original) +++ openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties Mon Sep 10 09:20:08 2007 @@ -59,6 +59,9 @@ bad-fg-field: Fetch group "{0}" in type "{1}" includes field "{2}", but \ this field is not declared in "{1}", or is not persistent. Currently, \ OpenJPA only supports declared fields in fetch groups. +missing-included-fg:"{0}" declares a fecth group "{1}" includes "{2}". But \ + the included fetch group "{2}" can not be found in "{0}". Currently, all \ + included fetch groups must be declared within the same entity scope. not-update-delete-query: Cannot perform an update or delete operation \ on select query: "{0}". not-select-query: Cannot perform a select on update or delete query: "{0}". @@ -141,3 +144,4 @@ EntityManagerFactory-displayorder: 50 EntityManagerFactory-expert: true EntityManagerFactory-interface: org.apache.openjpa.persistence.EntityManagerFactoryImpl + From commits-return-2364-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Mon Sep 10 19:13:41 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 79118 invoked from network); 10 Sep 2007 19:13:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Sep 2007 19:13:41 -0000 Received: (qmail 81206 invoked by uid 500); 10 Sep 2007 19:13:34 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 81186 invoked by uid 500); 10 Sep 2007 19:13:34 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 81172 invoked by uid 99); 10 Sep 2007 19:13:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Sep 2007 12:13:34 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Sep 2007 19:15:12 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 28D511A9832; Mon, 10 Sep 2007 12:13:18 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r574337 - /openjpa/trunk/openjpa-project/RELEASE-NOTES.html Date: Mon, 10 Sep 2007 19:13:17 -0000 To: commits@openjpa.apache.org From: pcl@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070910191318.28D511A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pcl Date: Mon Sep 10 12:13:17 2007 New Revision: 574337 URL: http://svn.apache.org/viewvc?rev=574337&view=rev Log: clarified prerequisites Modified: openjpa/trunk/openjpa-project/RELEASE-NOTES.html Modified: openjpa/trunk/openjpa-project/RELEASE-NOTES.html URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-project/RELEASE-NOTES.html?rev=574337&r1=574336&r2=574337&view=diff ============================================================================== --- openjpa/trunk/openjpa-project/RELEASE-NOTES.html (original) +++ openjpa/trunk/openjpa-project/RELEASE-NOTES.html Mon Sep 10 12:13:17 2007 @@ -60,9 +60,8 @@

Prerequisites

-OpenJPA requires Java 1.5 but will not compile with Java 6. For more -detail please see -http://issues.apache.org/jira/browse/OPENJPA-5 +In normal usage, OpenJPA requires Java 5 or higher and a relational +database of some sort.

Documentation

If you have questions about OpenJPA, a good source of information is the From commits-return-2365-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Mon Sep 10 19:15:27 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 79762 invoked from network); 10 Sep 2007 19:15:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Sep 2007 19:15:27 -0000 Received: (qmail 86410 invoked by uid 500); 10 Sep 2007 19:15:20 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 86352 invoked by uid 500); 10 Sep 2007 19:15:20 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 86343 invoked by uid 99); 10 Sep 2007 19:15:20 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Sep 2007 12:15:20 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Sep 2007 19:15:26 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 412C31A9832; Mon, 10 Sep 2007 12:15:06 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r574338 - /openjpa/branches/1.0.x/openjpa-project/RELEASE-NOTES.html Date: Mon, 10 Sep 2007 19:15:06 -0000 To: commits@openjpa.apache.org From: pcl@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070910191506.412C31A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pcl Date: Mon Sep 10 12:15:05 2007 New Revision: 574338 URL: http://svn.apache.org/viewvc?rev=574338&view=rev Log: release note clarification. svn merge -c 574337 ../../trunk Modified: openjpa/branches/1.0.x/openjpa-project/RELEASE-NOTES.html Modified: openjpa/branches/1.0.x/openjpa-project/RELEASE-NOTES.html URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-project/RELEASE-NOTES.html?rev=574338&r1=574337&r2=574338&view=diff ============================================================================== --- openjpa/branches/1.0.x/openjpa-project/RELEASE-NOTES.html (original) +++ openjpa/branches/1.0.x/openjpa-project/RELEASE-NOTES.html Mon Sep 10 12:15:05 2007 @@ -60,9 +60,8 @@

Prerequisites

-OpenJPA requires Java 1.5 but will not compile with Java 6. For more -detail please see -http://issues.apache.org/jira/browse/OPENJPA-5 +In normal usage, OpenJPA requires Java 5 or higher and a relational +database of some sort.

Documentation

If you have questions about OpenJPA, a good source of information is the From commits-return-2366-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Mon Sep 10 23:02:02 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 62867 invoked from network); 10 Sep 2007 23:02:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Sep 2007 23:02:02 -0000 Received: (qmail 31259 invoked by uid 500); 10 Sep 2007 23:01:55 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 31246 invoked by uid 500); 10 Sep 2007 23:01:55 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 31237 invoked by uid 99); 10 Sep 2007 23:01:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Sep 2007 16:01:55 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Sep 2007 23:02:01 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E563D1A9832; Mon, 10 Sep 2007 16:01:40 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r574398 - /openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/UUIDGenerator.java Date: Mon, 10 Sep 2007 23:01:40 -0000 To: commits@openjpa.apache.org From: kwsutter@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070910230140.E563D1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kwsutter Date: Mon Sep 10 16:01:39 2007 New Revision: 574398 URL: http://svn.apache.org/viewvc?rev=574398&view=rev Log: OPENJPA-361. Committing Albert's patch for the incorrect GREG_OFFSET (Gregorian Offset). Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/UUIDGenerator.java Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/UUIDGenerator.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/UUIDGenerator.java?rev=574398&r1=574397&r2=574398&view=diff ============================================================================== --- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/UUIDGenerator.java (original) +++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/UUIDGenerator.java Mon Sep 10 16:01:39 2007 @@ -61,7 +61,7 @@ // offset to move from 1/1/1970, which is 0-time for Java, to gregorian // 0-time 10/15/1582, and multiplier to go from 100nsec to msec units - private static final long GREG_OFFSET = 0x01b21dd213814000L; + private static final long GREG_OFFSET = 0xB1D069B5400L; private static final long MILLI_MULT = 10000L; // type of UUID -- time based From commits-return-2367-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Tue Sep 11 07:14:53 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 52471 invoked from network); 11 Sep 2007 07:14:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Sep 2007 07:14:53 -0000 Received: (qmail 82861 invoked by uid 500); 11 Sep 2007 07:14:47 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 82808 invoked by uid 500); 11 Sep 2007 07:14:46 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Delivered-To: moderator for commits@openjpa.apache.org Received: (qmail 75311 invoked by uid 99); 11 Sep 2007 05:32:53 -0000 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r574464 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/ Date: Tue, 11 Sep 2007 05:32:38 -0000 To: commits@openjpa.apache.org From: fancy@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070911053239.72CC21A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fancy Date: Mon Sep 10 22:32:37 2007 New Revision: 574464 URL: http://svn.apache.org/viewvc?rev=574464&view=rev Log: OPENJPA-360 SQL FOR UPDATE OF incorrectly generated for DB2 UDB version8.1 or earlier and DB2 ISeries V5R3 or earlier. These DB2 version also require the "optimize for row" clause appear before FOR UPDATE clause. Due to this requirement, the OPTIMIZE clause will appear before FOR UPDATE clause for all DB2 versions. Also fixed the affected testcases. Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SQLListenerTestCase.java Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?rev=574464&r1=574463&r2=574464&view=diff ============================================================================== --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java (original) +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java Mon Sep 10 22:32:37 2007 @@ -50,12 +50,12 @@ public String optimizeClause = "optimize for"; public String rowClause = "row"; protected int db2ServerType = 0; - protected static final int db2ISeriesV5R3OrEarlier = 1; - protected static final int db2UDBV81OrEarlier = 2; - protected static final int db2ZOSV8xOrLater = 3; - protected static final int db2UDBV82OrLater = 4; - protected static final int db2ISeriesV5R4OrLater = 5; - private static final String forUpdateOfClause = "FOR UPDATE OF"; + public static final int db2ISeriesV5R3OrEarlier = 1; + public static final int db2UDBV81OrEarlier = 2; + public static final int db2ZOSV8xOrLater = 3; + public static final int db2UDBV82OrLater = 4; + public static final int db2ISeriesV5R4OrLater = 5; + private static final String forUpdate = "FOR UPDATE"; private static final String withRSClause = "WITH RS"; private static final String withRRClause = "WITH RR"; private static final String useKeepUpdateLockClause @@ -313,9 +313,12 @@ * updateClause and isolationLevel hints */ protected String getForUpdateClause(JDBCFetchConfiguration fetch, - boolean forUpdate) { + boolean isForUpdate) { int isolationLevel; - StringBuffer forUpdateString = new StringBuffer(); + // For db2UDBV81OrEarlier and db2ISeriesV5R3OrEarlier: + // "optimize for" clause appears before "for update" clause. + StringBuffer forUpdateString = new StringBuffer( + getOptimizeClause(fetch)); try { // Determine the isolationLevel; the fetch // configuration data overrides the persistence.xml value @@ -324,16 +327,15 @@ else isolationLevel = conf.getTransactionIsolationConstant(); - if (forUpdate) { + if (isForUpdate) { switch(db2ServerType) { case db2ISeriesV5R3OrEarlier: case db2UDBV81OrEarlier: - if (isolationLevel == - Connection.TRANSACTION_READ_UNCOMMITTED) { - forUpdateString.append(" ").append(withRSClause) - .append(" ").append(forUpdateOfClause); - } else - forUpdateString.append(" ").append(forUpdateOfClause); + if (isolationLevel == Connection.TRANSACTION_SERIALIZABLE) + forUpdateString.append(" ").append(forUpdateClause); + else + forUpdateString.append(" ").append(forUpdate) + .append(" ").append(withRSClause); break; case db2ZOSV8xOrLater: case db2UDBV82OrLater: @@ -368,7 +370,7 @@ return forUpdateString.toString(); } - public boolean isDB2UDBV82OrLater() throws SQLException { + public boolean isDB2UDBV82OrLater() { boolean match = false; if ((databaseProductVersion.indexOf("SQL") != -1 || databaseProductName.indexOf("DB2/") != -1) @@ -377,8 +379,7 @@ return match; } - public boolean isDB2ZOSV8xOrLater() - throws SQLException { + public boolean isDB2ZOSV8xOrLater() { boolean match = false; if ((databaseProductVersion.indexOf("DSN") != -1 || databaseProductName.indexOf("DB2/") == -1) @@ -387,8 +388,7 @@ return match; } - public boolean isDB2ISeriesV5R3OrEarlier() - throws SQLException { + public boolean isDB2ISeriesV5R3OrEarlier() { boolean match = false; if (databaseProductName.indexOf("AS") != -1 && ((maj == 5 && min <=3) || maj < 5)) @@ -396,8 +396,7 @@ return match; } - public boolean isDB2ISeriesV5R4OrLater() - throws SQLException { + public boolean isDB2ISeriesV5R4OrLater() { boolean match = false; if (databaseProductName.indexOf("AS") != -1 && (maj >=6 || (maj == 5 && min >=4))) @@ -405,7 +404,7 @@ return match; } - public boolean isDB2UDBV81OrEarlier() throws SQLException { + public boolean isDB2UDBV81OrEarlier() { boolean match = false; if ((databaseProductVersion.indexOf("SQL") != -1 || databaseProductName.indexOf("DB2/") != -1) && @@ -465,17 +464,16 @@ } } - public SQLBuffer toSelect(Select sel, boolean forUpdate, - JDBCFetchConfiguration fetch) { - SQLBuffer buf = super.toSelect(sel, forUpdate, fetch); - - if (sel.getExpectedResultCount() > 0) { + protected String getOptimizeClause(JDBCFetchConfiguration fetch) { + if (sel != null && sel.getExpectedResultCount() > 0) { + StringBuffer buf = new StringBuffer(); buf.append(" ").append(optimizeClause).append(" ") .append(String.valueOf(sel.getExpectedResultCount())) .append(" ").append(rowClause); + return buf.toString(); } - return buf; + return ""; } public OpenJPAException newStoreException(String msg, SQLException[] causes, Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=574464&r1=574463&r2=574464&view=diff ============================================================================== --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java (original) +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java Mon Sep 10 22:32:37 2007 @@ -325,6 +325,7 @@ private Method _setBytes = null; private Method _setString = null; private Method _setCharStream = null; + protected transient Select sel = null; public DBDictionary() { fixedSizeTypeNameSet.addAll(Arrays.asList(new String[]{ @@ -1988,6 +1989,7 @@ */ public SQLBuffer toSelect(Select sel, boolean forUpdate, JDBCFetchConfiguration fetch) { + this.sel = sel; sel.addJoinClassConditions(); boolean update = forUpdate && sel.getFromSelect() == null; SQLBuffer select = getSelects(sel, false, update); @@ -2198,11 +2200,11 @@ * updateClause and isolationLevel hints */ protected String getForUpdateClause(JDBCFetchConfiguration fetch, - boolean forUpdate) { + boolean isForUpdate) { if (fetch != null && fetch.getIsolation() != -1) { throw new InvalidStateException(_loc.get( "isolation-level-config-not-supported", getClass().getName())); - } else if (forUpdate && !simulateLocking) { + } else if (isForUpdate && !simulateLocking) { assertSupport(supportsSelectForUpdate, "SupportsSelectForUpdate"); return forUpdateClause; } else { Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java?rev=574464&r1=574463&r2=574464&view=diff ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java (original) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java Mon Sep 10 22:32:37 2007 @@ -81,37 +81,23 @@ q.getResultList(); if (dict instanceof DB2Dictionary) { - if ((((DB2Dictionary) dict).getDb2ServerType() == 1) - || (((DB2Dictionary) dict).getDb2ServerType()== 2)) { + int db2server = ((DB2Dictionary) dict).getDb2ServerType(); + if (db2server == DB2Dictionary.db2ISeriesV5R3OrEarlier + || db2server == DB2Dictionary.db2UDBV81OrEarlier) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.id, t0.booleanField, t0.byteField," - + " t0.charField, t0.dateField, t0.doubleField," - + " t0.floatField, t0.intField, t0.longField, " - + "t0.shortField, t0.stringField FROM " - + "AllFieldTypes t0 WHERE \\(t0.intField = \\?\\) " - + " FOR UPDATE OF"); + assertContainsSQL(" FOR UPDATE"); } // it is DB2 v82 or later - else if ((((DB2Dictionary) dict).getDb2ServerType() == 3) - || (((DB2Dictionary) dict).getDb2ServerType() == 4)) { + else if (db2server == DB2Dictionary.db2ZOSV8xOrLater + || db2server == DB2Dictionary.db2UDBV82OrLater) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.id, t0.booleanField, t0.byteField," - + " t0.charField, t0.dateField, t0.doubleField," - + " t0.floatField, t0.intField, t0.longField, " - + "t0.shortField, t0.stringField FROM " - + "AllFieldTypes t0 WHERE \\(t0.intField = \\?\\) " - + " FOR READ ONLY WITH RR USE AND KEEP " + assertContainsSQL(" FOR READ ONLY WITH RR USE AND KEEP " + "UPDATE LOCKS"); } - else if (((DB2Dictionary) dict).getDb2ServerType() == 5) { + else if (db2server == DB2Dictionary.db2ISeriesV5R4OrLater) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.id, t0.booleanField, t0.byteField," - + " t0.charField, t0.dateField, t0.doubleField," - + " t0.floatField, t0.intField, t0.longField, " - + "t0.shortField, t0.stringField FROM " - + "AllFieldTypes t0 WHERE \\(t0.intField = \\?\\) " - + " FOR READ ONLY WITH RR USE AND KEEP EXCLUSIVE " - + "LOCKS"); + assertContainsSQL(" FOR READ ONLY WITH RR USE AND KEEP" + + " EXCLUSIVE LOCKS"); } else { fail("OpenJPA currently only supports " @@ -124,37 +110,25 @@ .setIsolation(IsolationLevel.SERIALIZABLE); em.find(AllFieldTypes.class, 0); if (dict instanceof DB2Dictionary ) { - if ((((DB2Dictionary) dict).getDb2ServerType() == 1) - || (((DB2Dictionary) dict).getDb2ServerType()== 2)) { + int db2server = ((DB2Dictionary) dict).getDb2ServerType(); + if (db2server == DB2Dictionary.db2ISeriesV5R3OrEarlier + || db2server == DB2Dictionary.db2UDBV81OrEarlier) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.booleanField, t0.byteField, " - + "t0.charField, t0.dateField, t0.doubleField," - + " t0.floatField, t0.intField, t0.longField," - + " t0.shortField, t0.stringField FROM " - + "AllFieldTypes t0 WHERE t0.id = \\? " - + " FOR UPDATE OF optimize for 1 row"); + assertContainsSQL(" optimize for 1 row FOR UPDATE"); } // it is DB2 v82 or later - else if ((((DB2Dictionary) dict).getDb2ServerType() == 3) - || (((DB2Dictionary) dict).getDb2ServerType() == 4)) { + else if (db2server == DB2Dictionary.db2ZOSV8xOrLater + || db2server == DB2Dictionary.db2UDBV82OrLater) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.booleanField, t0.byteField, " - + "t0.charField, t0.dateField, t0.doubleField," - + " t0.floatField, t0.intField, t0.longField," - + " t0.shortField, t0.stringField FROM " - + "AllFieldTypes t0 WHERE t0.id = \\? " + assertContainsSQL(" optimize for 1 row" + " FOR READ ONLY WITH RR USE AND KEEP UPDATE LOCKS" - + " optimize for 1 row"); + ); } - else if (((DB2Dictionary) dict).getDb2ServerType() == 5) { + else if (db2server == DB2Dictionary.db2ISeriesV5R4OrLater) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.booleanField, t0.byteField, " - + "t0.charField, t0.dateField, t0.doubleField," - + " t0.floatField, t0.intField, t0.longField," - + " t0.shortField, t0.stringField FROM " - + "AllFieldTypes t0 WHERE t0.id = \\? " + assertContainsSQL(" optimize for 1 row" + " FOR READ ONLY WITH RR USE AND KEEP EXCLUSIVE" - + " LOCKS optimize for 1 row"); + + " LOCKS"); } else { fail("OpenJPA currently only supports per-query" Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java?rev=574464&r1=574463&r2=574464&view=diff ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java (original) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java Mon Sep 10 22:32:37 2007 @@ -81,22 +81,14 @@ } if (dict instanceof DB2Dictionary) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.id, t0.booleanField, t0.byteField," + - " t0.charField, t0.dateField, t0.doubleField, " + - "t0.floatField, t0.intField, t0.longField, " + - "t0.shortField, t0.stringField FROM AllFieldTypes " + - "t0 WHERE \\(t0.intField = \\?\\) optimize for 8 row"); + assertContainsSQL(" optimize for 8 row"); } } else { em.find(AllFieldTypes.class, 0); if (dict instanceof DB2Dictionary ) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.booleanField, t0.byteField, " + - "t0.charField, t0.dateField, t0.doubleField, " + - "t0.floatField, t0.intField, t0.longField, " + - "t0.shortField, t0.stringField FROM AllFieldTypes" + - " t0 WHERE t0.id = \\? optimize for 1 row"); + assertContainsSQL(" optimize for 1 row"); } } Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java?rev=574464&r1=574463&r2=574464&view=diff ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java (original) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java Mon Sep 10 22:32:37 2007 @@ -33,7 +33,14 @@ extends SQLListenerTestCase { public void setUp() { - setUp(AllFieldTypes.class, + setUp( +// "openjpa.ConnectionDriverName", +// "org.apache.commons.dbcp.BasicDataSource", + + "openjpa.ConnectionProperties", + "DriverClassName=com.ibm.db2.jcc.DB2Driver,Url=jdbc:db2:demodb" + ,"openjpa.jdbc.SynchronizeMappings", + AllFieldTypes.class, "openjpa.Optimistic", "false", "openjpa.LockManager", "pessimistic", "openjpa.ReadLockLevel", "none"); @@ -57,37 +64,24 @@ em.find(AllFieldTypes.class, 0); assertEquals(1, sql.size()); if (dict instanceof DB2Dictionary) { - if ((((DB2Dictionary) dict).getDb2ServerType() == 1) - || (((DB2Dictionary) dict).getDb2ServerType()== 2)) { + int db2server = ((DB2Dictionary) dict).getDb2ServerType(); + if (db2server == DB2Dictionary.db2ISeriesV5R3OrEarlier + || db2server == DB2Dictionary.db2UDBV81OrEarlier) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.booleanField, t0.byteField, " - + "t0.charField, t0.dateField, t0.doubleField," - + " t0.floatField, t0.intField, t0.longField," - + " t0.shortField, t0.stringField FROM " - + "AllFieldTypes t0 WHERE t0.id = \\? " - + " FOR UPDATE OF optimize for 1 row"); + assertContainsSQL(" optimize for 1 row FOR UPDATE"); } // it is DB2 v82 or later - else if ((((DB2Dictionary) dict).getDb2ServerType() == 3) - || (((DB2Dictionary) dict).getDb2ServerType() == 4)) { + else if (db2server == DB2Dictionary.db2ZOSV8xOrLater + || db2server == DB2Dictionary.db2UDBV82OrLater) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.booleanField, t0.byteField, " - + "t0.charField, t0.dateField, t0.doubleField," - + " t0.floatField, t0.intField, t0.longField," - + " t0.shortField, t0.stringField FROM " - + "AllFieldTypes t0 WHERE t0.id = \\? " - + " FOR READ ONLY WITH RS USE AND KEEP UPDATE LOCKS" - + " optimize for 1 row"); + assertContainsSQL(" optimize for 1 row" + + " FOR READ ONLY WITH RS USE AND KEEP UPDATE LOCKS"); } - else if (((DB2Dictionary) dict).getDb2ServerType() == 5) { + else if (db2server == DB2Dictionary.db2ISeriesV5R4OrLater) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.booleanField, t0.byteField, " - + "t0.charField, t0.dateField, t0.doubleField," - + " t0.floatField, t0.intField, t0.longField," - + " t0.shortField, t0.stringField FROM " - + "AllFieldTypes t0 WHERE t0.id = \\? " + assertContainsSQL(" optimize for 1 row" + " FOR READ ONLY WITH RS USE AND KEEP EXCLUSIVE LOCKS" - + " optimize for 1 row"); + ); } else { fail("OpenJPA currently only supports per-query isolation " Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SQLListenerTestCase.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SQLListenerTestCase.java?rev=574464&r1=574463&r2=574464&view=diff ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SQLListenerTestCase.java (original) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SQLListenerTestCase.java Mon Sep 10 22:32:37 2007 @@ -78,6 +78,21 @@ + " should not have been executed in SQL statements: " + sql); } + /** + * Confirm that the executed SQL String contains the specified sqlExp. + * + * @param sqlExp the SQL expression. E.g., "SELECT BADCOLUMN .*" + */ + public void assertContainsSQL(String sqlExp) { + for (String statement : sql) { + if (statement.contains(sqlExp)) + return; + } + + fail("Expected regular expression <" + sqlExp + "> to be" + + " contained in SQL statements: " + sql); + } + public class Listener extends AbstractJDBCListener { From commits-return-2368-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Tue Sep 11 13:29:09 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 95369 invoked from network); 11 Sep 2007 13:29:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Sep 2007 13:29:09 -0000 Received: (qmail 15685 invoked by uid 500); 11 Sep 2007 13:29:03 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 15629 invoked by uid 500); 11 Sep 2007 13:29:03 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 15620 invoked by uid 99); 11 Sep 2007 13:29:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Sep 2007 06:29:02 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Sep 2007 13:30:42 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 987421A9832; Tue, 11 Sep 2007 06:28:46 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r574594 - /openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/UUIDGenerator.java Date: Tue, 11 Sep 2007 13:28:46 -0000 To: commits@openjpa.apache.org From: kwsutter@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070911132846.987421A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kwsutter Date: Tue Sep 11 06:28:45 2007 New Revision: 574594 URL: http://svn.apache.org/viewvc?rev=574594&view=rev Log: OPENJPA-361. Committing Albert's patch for the incorrect GREG_OFFSET (Gregorian Offset) for the 1.0.x branch. Modified: openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/UUIDGenerator.java Modified: openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/UUIDGenerator.java URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/UUIDGenerator.java?rev=574594&r1=574593&r2=574594&view=diff ============================================================================== --- openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/UUIDGenerator.java (original) +++ openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/UUIDGenerator.java Tue Sep 11 06:28:45 2007 @@ -61,7 +61,7 @@ // offset to move from 1/1/1970, which is 0-time for Java, to gregorian // 0-time 10/15/1582, and multiplier to go from 100nsec to msec units - private static final long GREG_OFFSET = 0x01b21dd213814000L; + private static final long GREG_OFFSET = 0xB1D069B5400L; private static final long MILLI_MULT = 10000L; // type of UUID -- time based From commits-return-2369-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Tue Sep 11 15:32:29 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 72007 invoked from network); 11 Sep 2007 15:32:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Sep 2007 15:32:29 -0000 Received: (qmail 86830 invoked by uid 500); 11 Sep 2007 15:32:23 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 86814 invoked by uid 500); 11 Sep 2007 15:32:23 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 86805 invoked by uid 99); 11 Sep 2007 15:32:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Sep 2007 08:32:22 -0700 X-ASF-Spam-Status: No, hits=-96.3 required=10.0 tests=ALL_TRUSTED,HTML_MESSAGE,MIME_HTML_ONLY X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Sep 2007 15:32:20 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 084EC71403E for ; Tue, 11 Sep 2007 08:32:00 -0700 (PDT) Message-ID: <7641813.1189524720022.JavaMail.www-data@brutus> Date: Tue, 11 Sep 2007 08:32:00 -0700 (PDT) From: confluence@apache.org To: commits@openjpa.apache.org Subject: [CONF] OpenJPA: OpenJPA Development Resources (page edited) MIME-Version: 1.0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org

OpenJPA Development Resources has been edited by Craig Russell (Sep 11, 2007).

(View changes)

Content:

Getting Involved

Most of the OpenJPA discussions happen on the dev@openjpa.apache.org mailing list. For more details see OpenJPA mailing lists. For more general discussion about Apache mailing lists, see the Apache mailing lists page.

Development Resources

From commits-return-2370-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Tue Sep 11 15:49:29 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 1762 invoked from network); 11 Sep 2007 15:49:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Sep 2007 15:49:29 -0000 Received: (qmail 24865 invoked by uid 500); 11 Sep 2007 15:49:23 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 24807 invoked by uid 500); 11 Sep 2007 15:49:23 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 24798 invoked by uid 99); 11 Sep 2007 15:49:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Sep 2007 08:49:22 -0700 X-ASF-Spam-Status: No, hits=-96.3 required=10.0 tests=ALL_TRUSTED,HTML_MESSAGE,MIME_HTML_ONLY X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Sep 2007 15:49:20 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 068C8714159 for ; Tue, 11 Sep 2007 08:49:00 -0700 (PDT) Message-ID: <15553619.1189525740018.JavaMail.www-data@brutus> Date: Tue, 11 Sep 2007 08:49:00 -0700 (PDT) From: confluence@apache.org To: commits@openjpa.apache.org Subject: [CONF] OpenJPA: Development Process (page created) MIME-Version: 1.0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org

Development Process has been created by Craig Russell (Sep 11, 2007).

Content:

DRAFT OpenJPA Development Process

Tracking issues and changes

  • A JIRA issue is required for any substantive change.
    In order to keep the list of JIRA issues under control, it is expected that any controversial issue or user request for a feature or design change be discussed on the dev list prior to entering it into JIRA.
  • JIRA issues are not needed for small (e.g., typos) changes.
  • Issue discussions
    The preferred place of discussion on issues is the JIRA created for the task. If discussions occur on the dev list outside the JIRA, a link to the beginning of the mail thread on the issue should be placed in the JIRA issue so that users looking through JIRA can easily view the thread of discussion on an issue. Please keep the Subject line the same so that the email thread hangs together. If discussion occurs on the dev list, it's also recommended that a summary/conclusion on the thread be recorded in the JIRA issue itself.

Code Reviews

  • for public API changes:
    RTC These changes have potentially broad effects on developers and users, and therefore will require a code review and vote. Since some of these changes will affect the API docs ('specs'), everyone within the community is encouraged to review and vote. The Committer votes are binding, but the sentiment of the entire community will be strongly considered.
  • for all other changes:
    CTR Although CTR is what is specified, developers should feel comfortable requesting the list for peer review before committing.

Testing

  • Developing test cases and running test suites are desired but not required prior to an integration. If unit tests are created for a change, the developer is encouraged to add them to the JIRA issue for sharing.
  • When fixing a bug, it is strongly encouraged to attach to the JIRA a test case that fails prior to the fix and succeeds after the fix is applied. When the fix is committed, the test case should be committed as well.

From commits-return-2371-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Tue Sep 11 18:03:21 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 66979 invoked from network); 11 Sep 2007 18:03:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Sep 2007 18:03:21 -0000 Received: (qmail 35825 invoked by uid 500); 11 Sep 2007 18:03:14 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 35810 invoked by uid 500); 11 Sep 2007 18:03:14 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Delivered-To: moderator for commits@openjpa.apache.org Received: (qmail 33316 invoked by uid 99); 11 Sep 2007 17:59:59 -0000 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r574653 - in /openjpa/branches/1.0.x: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/... Date: Tue, 11 Sep 2007 17:59:38 -0000 To: commits@openjpa.apache.org From: fancy@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070911175939.9DE551A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fancy Date: Tue Sep 11 10:59:38 2007 New Revision: 574653 URL: http://svn.apache.org/viewvc?rev=574653&view=rev Log: OPENJPA-360 SQL FOR UPDATE OF incorrectly generated for DB2 UDB version8.1 or earlier and DB2 ISeries V5R3 or earlier. These DB2 version also require the "optimize for row" clause appear before FOR UPDATE clause. Due to this requirement, the OPTIMIZE clause will appear before FOR UPDATE clause for all DB2 versions. Also fixed the affected testcases. Same fix retrofit to OpenJPA 1.0.x branch. Modified: openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SQLListenerTestCase.java Modified: openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?rev=574653&r1=574652&r2=574653&view=diff ============================================================================== --- openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java (original) +++ openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java Tue Sep 11 10:59:38 2007 @@ -50,12 +50,12 @@ public String optimizeClause = "optimize for"; public String rowClause = "row"; protected int db2ServerType = 0; - protected static final int db2ISeriesV5R3OrEarlier = 1; - protected static final int db2UDBV81OrEarlier = 2; - protected static final int db2ZOSV8xOrLater = 3; - protected static final int db2UDBV82OrLater = 4; - protected static final int db2ISeriesV5R4OrLater = 5; - private static final String forUpdateOfClause = "FOR UPDATE OF"; + public static final int db2ISeriesV5R3OrEarlier = 1; + public static final int db2UDBV81OrEarlier = 2; + public static final int db2ZOSV8xOrLater = 3; + public static final int db2UDBV82OrLater = 4; + public static final int db2ISeriesV5R4OrLater = 5; + private static final String forUpdate = "FOR UPDATE"; private static final String withRSClause = "WITH RS"; private static final String withRRClause = "WITH RR"; private static final String useKeepUpdateLockClause @@ -286,9 +286,12 @@ * updateClause and isolationLevel hints */ protected String getForUpdateClause(JDBCFetchConfiguration fetch, - boolean forUpdate) { + boolean isForUpdate) { int isolationLevel; - StringBuffer forUpdateString = new StringBuffer(); + // For db2UDBV81OrEarlier and db2ISeriesV5R3OrEarlier: + // "optimize for" clause appears before "for update" clause. + StringBuffer forUpdateString = new StringBuffer( + getOptimizeClause(fetch)); try { // Determine the isolationLevel; the fetch // configuration data overrides the persistence.xml value @@ -297,16 +300,15 @@ else isolationLevel = conf.getTransactionIsolationConstant(); - if (forUpdate) { + if (isForUpdate) { switch(db2ServerType) { case db2ISeriesV5R3OrEarlier: case db2UDBV81OrEarlier: - if (isolationLevel == - Connection.TRANSACTION_READ_UNCOMMITTED) { - forUpdateString.append(" ").append(withRSClause) - .append(" ").append(forUpdateOfClause); - } else - forUpdateString.append(" ").append(forUpdateOfClause); + if (isolationLevel == Connection.TRANSACTION_SERIALIZABLE) + forUpdateString.append(" ").append(forUpdateClause); + else + forUpdateString.append(" ").append(forUpdate) + .append(" ").append(withRSClause); break; case db2ZOSV8xOrLater: case db2UDBV82OrLater: @@ -341,7 +343,7 @@ return forUpdateString.toString(); } - public boolean isDB2UDBV82OrLater() throws SQLException { + public boolean isDB2UDBV82OrLater() { boolean match = false; if ((databaseProductVersion.indexOf("SQL") != -1 || databaseProductName.indexOf("DB2/") != -1) @@ -350,8 +352,7 @@ return match; } - public boolean isDB2ZOSV8xOrLater() - throws SQLException { + public boolean isDB2ZOSV8xOrLater() { boolean match = false; if ((databaseProductVersion.indexOf("DSN") != -1 || databaseProductName.indexOf("DB2/") == -1) @@ -360,8 +361,7 @@ return match; } - public boolean isDB2ISeriesV5R3OrEarlier() - throws SQLException { + public boolean isDB2ISeriesV5R3OrEarlier() { boolean match = false; if (databaseProductName.indexOf("AS") != -1 && ((maj == 5 && min <=3) || maj < 5)) @@ -369,8 +369,7 @@ return match; } - public boolean isDB2ISeriesV5R4OrLater() - throws SQLException { + public boolean isDB2ISeriesV5R4OrLater() { boolean match = false; if (databaseProductName.indexOf("AS") != -1 && (maj >=6 || (maj == 5 && min >=4))) @@ -378,7 +377,7 @@ return match; } - public boolean isDB2UDBV81OrEarlier() throws SQLException { + public boolean isDB2UDBV81OrEarlier() { boolean match = false; if ((databaseProductVersion.indexOf("SQL") != -1 || databaseProductName.indexOf("DB2/") != -1) && @@ -438,17 +437,16 @@ } } - public SQLBuffer toSelect(Select sel, boolean forUpdate, - JDBCFetchConfiguration fetch) { - SQLBuffer buf = super.toSelect(sel, forUpdate, fetch); - - if (sel.getExpectedResultCount() > 0) { + protected String getOptimizeClause(JDBCFetchConfiguration fetch) { + if (sel != null && sel.getExpectedResultCount() > 0) { + StringBuffer buf = new StringBuffer(); buf.append(" ").append(optimizeClause).append(" ") .append(String.valueOf(sel.getExpectedResultCount())) .append(" ").append(rowClause); + return buf.toString(); } - return buf; + return ""; } public OpenJPAException newStoreException(String msg, SQLException[] causes, Modified: openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=574653&r1=574652&r2=574653&view=diff ============================================================================== --- openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java (original) +++ openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java Tue Sep 11 10:59:38 2007 @@ -319,6 +319,7 @@ private Method _setBytes = null; private Method _setString = null; private Method _setCharStream = null; + protected transient Select sel = null; public DBDictionary() { fixedSizeTypeNameSet.addAll(Arrays.asList(new String[]{ @@ -1982,6 +1983,7 @@ */ public SQLBuffer toSelect(Select sel, boolean forUpdate, JDBCFetchConfiguration fetch) { + this.sel = sel; sel.addJoinClassConditions(); boolean update = forUpdate && sel.getFromSelect() == null; SQLBuffer select = getSelects(sel, false, update); @@ -2192,11 +2194,11 @@ * updateClause and isolationLevel hints */ protected String getForUpdateClause(JDBCFetchConfiguration fetch, - boolean forUpdate) { + boolean isForUpdate) { if (fetch != null && fetch.getIsolation() != -1) { throw new InvalidStateException(_loc.get( "isolation-level-config-not-supported", getClass().getName())); - } else if (forUpdate && !simulateLocking) { + } else if (isForUpdate && !simulateLocking) { assertSupport(supportsSelectForUpdate, "SupportsSelectForUpdate"); return forUpdateClause; } else { @@ -3893,5 +3895,4 @@ public String getCastFunction(Val val, String func) { return func; } - } Modified: openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java?rev=574653&r1=574652&r2=574653&view=diff ============================================================================== --- openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java (original) +++ openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestIsolationLevelOverride.java Tue Sep 11 10:59:38 2007 @@ -81,37 +81,23 @@ q.getResultList(); if (dict instanceof DB2Dictionary) { - if ((((DB2Dictionary) dict).getDb2ServerType() == 1) - || (((DB2Dictionary) dict).getDb2ServerType()== 2)) { + int db2server = ((DB2Dictionary) dict).getDb2ServerType(); + if (db2server == DB2Dictionary.db2ISeriesV5R3OrEarlier + || db2server == DB2Dictionary.db2UDBV81OrEarlier) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.id, t0.booleanField, t0.byteField," - + " t0.charField, t0.dateField, t0.doubleField," - + " t0.floatField, t0.intField, t0.longField, " - + "t0.shortField, t0.stringField FROM " - + "AllFieldTypes t0 WHERE \\(t0.intField = \\?\\) " - + " FOR UPDATE OF"); + assertContainsSQL(" FOR UPDATE"); } // it is DB2 v82 or later - else if ((((DB2Dictionary) dict).getDb2ServerType() == 3) - || (((DB2Dictionary) dict).getDb2ServerType() == 4)) { + else if (db2server == DB2Dictionary.db2ZOSV8xOrLater + || db2server == DB2Dictionary.db2UDBV82OrLater) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.id, t0.booleanField, t0.byteField," - + " t0.charField, t0.dateField, t0.doubleField," - + " t0.floatField, t0.intField, t0.longField, " - + "t0.shortField, t0.stringField FROM " - + "AllFieldTypes t0 WHERE \\(t0.intField = \\?\\) " - + " FOR READ ONLY WITH RR USE AND KEEP " + assertContainsSQL(" FOR READ ONLY WITH RR USE AND KEEP " + "UPDATE LOCKS"); } - else if (((DB2Dictionary) dict).getDb2ServerType() == 5) { + else if (db2server == DB2Dictionary.db2ISeriesV5R4OrLater) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.id, t0.booleanField, t0.byteField," - + " t0.charField, t0.dateField, t0.doubleField," - + " t0.floatField, t0.intField, t0.longField, " - + "t0.shortField, t0.stringField FROM " - + "AllFieldTypes t0 WHERE \\(t0.intField = \\?\\) " - + " FOR READ ONLY WITH RR USE AND KEEP EXCLUSIVE " - + "LOCKS"); + assertContainsSQL(" FOR READ ONLY WITH RR USE AND KEEP" + + " EXCLUSIVE LOCKS"); } else { fail("OpenJPA currently only supports " @@ -124,37 +110,25 @@ .setIsolation(IsolationLevel.SERIALIZABLE); em.find(AllFieldTypes.class, 0); if (dict instanceof DB2Dictionary ) { - if ((((DB2Dictionary) dict).getDb2ServerType() == 1) - || (((DB2Dictionary) dict).getDb2ServerType()== 2)) { + int db2server = ((DB2Dictionary) dict).getDb2ServerType(); + if (db2server == DB2Dictionary.db2ISeriesV5R3OrEarlier + || db2server == DB2Dictionary.db2UDBV81OrEarlier) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.booleanField, t0.byteField, " - + "t0.charField, t0.dateField, t0.doubleField," - + " t0.floatField, t0.intField, t0.longField," - + " t0.shortField, t0.stringField FROM " - + "AllFieldTypes t0 WHERE t0.id = \\? " - + " FOR UPDATE OF optimize for 1 row"); + assertContainsSQL(" optimize for 1 row FOR UPDATE"); } // it is DB2 v82 or later - else if ((((DB2Dictionary) dict).getDb2ServerType() == 3) - || (((DB2Dictionary) dict).getDb2ServerType() == 4)) { + else if (db2server == DB2Dictionary.db2ZOSV8xOrLater + || db2server == DB2Dictionary.db2UDBV82OrLater) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.booleanField, t0.byteField, " - + "t0.charField, t0.dateField, t0.doubleField," - + " t0.floatField, t0.intField, t0.longField," - + " t0.shortField, t0.stringField FROM " - + "AllFieldTypes t0 WHERE t0.id = \\? " + assertContainsSQL(" optimize for 1 row" + " FOR READ ONLY WITH RR USE AND KEEP UPDATE LOCKS" - + " optimize for 1 row"); + ); } - else if (((DB2Dictionary) dict).getDb2ServerType() == 5) { + else if (db2server == DB2Dictionary.db2ISeriesV5R4OrLater) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.booleanField, t0.byteField, " - + "t0.charField, t0.dateField, t0.doubleField," - + " t0.floatField, t0.intField, t0.longField," - + " t0.shortField, t0.stringField FROM " - + "AllFieldTypes t0 WHERE t0.id = \\? " + assertContainsSQL(" optimize for 1 row" + " FOR READ ONLY WITH RR USE AND KEEP EXCLUSIVE" - + " LOCKS optimize for 1 row"); + + " LOCKS"); } else { fail("OpenJPA currently only supports per-query" Modified: openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java?rev=574653&r1=574652&r2=574653&view=diff ============================================================================== --- openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java (original) +++ openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestOptimizeForClause.java Tue Sep 11 10:59:38 2007 @@ -81,22 +81,14 @@ } if (dict instanceof DB2Dictionary) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.id, t0.booleanField, t0.byteField," + - " t0.charField, t0.dateField, t0.doubleField, " + - "t0.floatField, t0.intField, t0.longField, " + - "t0.shortField, t0.stringField FROM AllFieldTypes " + - "t0 WHERE \\(t0.intField = \\?\\) optimize for 8 row"); + assertContainsSQL(" optimize for 8 row"); } } else { em.find(AllFieldTypes.class, 0); if (dict instanceof DB2Dictionary ) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.booleanField, t0.byteField, " + - "t0.charField, t0.dateField, t0.doubleField, " + - "t0.floatField, t0.intField, t0.longField, " + - "t0.shortField, t0.stringField FROM AllFieldTypes" + - " t0 WHERE t0.id = \\? optimize for 1 row"); + assertContainsSQL(" optimize for 1 row"); } } Modified: openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java?rev=574653&r1=574652&r2=574653&view=diff ============================================================================== --- openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java (original) +++ openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java Tue Sep 11 10:59:38 2007 @@ -33,7 +33,14 @@ extends SQLListenerTestCase { public void setUp() { - setUp(AllFieldTypes.class, + setUp( +// "openjpa.ConnectionDriverName", +// "org.apache.commons.dbcp.BasicDataSource", + + "openjpa.ConnectionProperties", + "DriverClassName=com.ibm.db2.jcc.DB2Driver,Url=jdbc:db2:demodb" + ,"openjpa.jdbc.SynchronizeMappings", + AllFieldTypes.class, "openjpa.Optimistic", "false", "openjpa.LockManager", "pessimistic", "openjpa.ReadLockLevel", "none"); @@ -57,37 +64,24 @@ em.find(AllFieldTypes.class, 0); assertEquals(1, sql.size()); if (dict instanceof DB2Dictionary) { - if ((((DB2Dictionary) dict).getDb2ServerType() == 1) - || (((DB2Dictionary) dict).getDb2ServerType()== 2)) { + int db2server = ((DB2Dictionary) dict).getDb2ServerType(); + if (db2server == DB2Dictionary.db2ISeriesV5R3OrEarlier + || db2server == DB2Dictionary.db2UDBV81OrEarlier) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.booleanField, t0.byteField, " - + "t0.charField, t0.dateField, t0.doubleField," - + " t0.floatField, t0.intField, t0.longField," - + " t0.shortField, t0.stringField FROM " - + "AllFieldTypes t0 WHERE t0.id = \\? " - + " FOR UPDATE OF optimize for 1 row"); + assertContainsSQL(" optimize for 1 row FOR UPDATE"); } // it is DB2 v82 or later - else if ((((DB2Dictionary) dict).getDb2ServerType() == 3) - || (((DB2Dictionary) dict).getDb2ServerType() == 4)) { + else if (db2server == DB2Dictionary.db2ZOSV8xOrLater + || db2server == DB2Dictionary.db2UDBV82OrLater) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.booleanField, t0.byteField, " - + "t0.charField, t0.dateField, t0.doubleField," - + " t0.floatField, t0.intField, t0.longField," - + " t0.shortField, t0.stringField FROM " - + "AllFieldTypes t0 WHERE t0.id = \\? " - + " FOR READ ONLY WITH RS USE AND KEEP UPDATE LOCKS" - + " optimize for 1 row"); + assertContainsSQL(" optimize for 1 row" + + " FOR READ ONLY WITH RS USE AND KEEP UPDATE LOCKS"); } - else if (((DB2Dictionary) dict).getDb2ServerType() == 5) { + else if (db2server == DB2Dictionary.db2ISeriesV5R4OrLater) { assertEquals(1, sql.size()); - assertSQL("SELECT t0.booleanField, t0.byteField, " - + "t0.charField, t0.dateField, t0.doubleField," - + " t0.floatField, t0.intField, t0.longField," - + " t0.shortField, t0.stringField FROM " - + "AllFieldTypes t0 WHERE t0.id = \\? " + assertContainsSQL(" optimize for 1 row" + " FOR READ ONLY WITH RS USE AND KEEP EXCLUSIVE LOCKS" - + " optimize for 1 row"); + ); } else { fail("OpenJPA currently only supports per-query isolation " Modified: openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SQLListenerTestCase.java URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SQLListenerTestCase.java?rev=574653&r1=574652&r2=574653&view=diff ============================================================================== --- openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SQLListenerTestCase.java (original) +++ openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SQLListenerTestCase.java Tue Sep 11 10:59:38 2007 @@ -78,6 +78,21 @@ + " should not have been executed in SQL statements: " + sql); } + /** + * Confirm that the executed SQL String contains the specified sqlExp. + * + * @param sqlExp the SQL expression. E.g., "SELECT BADCOLUMN .*" + */ + public void assertContainsSQL(String sqlExp) { + for (String statement : sql) { + if (statement.contains(sqlExp)) + return; + } + + fail("Expected regular expression <" + sqlExp + "> to be" + + " contained in SQL statements: " + sql); + } + public class Listener extends AbstractJDBCListener { From commits-return-2372-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Wed Sep 12 16:46:27 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 91010 invoked from network); 12 Sep 2007 16:46:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Sep 2007 16:46:27 -0000 Received: (qmail 67630 invoked by uid 500); 12 Sep 2007 16:46:20 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 67614 invoked by uid 500); 12 Sep 2007 16:46:20 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 67602 invoked by uid 99); 12 Sep 2007 16:46:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Sep 2007 09:46:20 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Sep 2007 16:48:03 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id DDEAC1A9832; Wed, 12 Sep 2007 09:46:03 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r575008 - in /openjpa: branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/ trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/ Date: Wed, 12 Sep 2007 16:46:03 -0000 To: commits@openjpa.apache.org From: kwsutter@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070912164603.DDEAC1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kwsutter Date: Wed Sep 12 09:45:59 2007 New Revision: 575008 URL: http://svn.apache.org/viewvc?rev=575008&view=rev Log: OPENJPA-360. Remove code dependencies on DB2 libraries from unit tests. Modified: openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java Modified: openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java?rev=575008&r1=575007&r2=575008&view=diff ============================================================================== --- openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java (original) +++ openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java Wed Sep 12 09:45:59 2007 @@ -33,14 +33,7 @@ extends SQLListenerTestCase { public void setUp() { - setUp( -// "openjpa.ConnectionDriverName", -// "org.apache.commons.dbcp.BasicDataSource", - - "openjpa.ConnectionProperties", - "DriverClassName=com.ibm.db2.jcc.DB2Driver,Url=jdbc:db2:demodb" - ,"openjpa.jdbc.SynchronizeMappings", - AllFieldTypes.class, + setUp(AllFieldTypes.class, "openjpa.Optimistic", "false", "openjpa.LockManager", "pessimistic", "openjpa.ReadLockLevel", "none"); Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java?rev=575008&r1=575007&r2=575008&view=diff ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java (original) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/TestSelectForUpdateOverride.java Wed Sep 12 09:45:59 2007 @@ -33,14 +33,7 @@ extends SQLListenerTestCase { public void setUp() { - setUp( -// "openjpa.ConnectionDriverName", -// "org.apache.commons.dbcp.BasicDataSource", - - "openjpa.ConnectionProperties", - "DriverClassName=com.ibm.db2.jcc.DB2Driver,Url=jdbc:db2:demodb" - ,"openjpa.jdbc.SynchronizeMappings", - AllFieldTypes.class, + setUp(AllFieldTypes.class, "openjpa.Optimistic", "false", "openjpa.LockManager", "pessimistic", "openjpa.ReadLockLevel", "none"); From commits-return-2373-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Wed Sep 12 21:09:19 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 23718 invoked from network); 12 Sep 2007 21:09:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Sep 2007 21:09:19 -0000 Received: (qmail 18179 invoked by uid 500); 12 Sep 2007 21:09:12 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 18163 invoked by uid 500); 12 Sep 2007 21:09:12 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 18154 invoked by uid 99); 12 Sep 2007 21:09:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Sep 2007 14:09:12 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Sep 2007 21:10:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 70C471A9832; Wed, 12 Sep 2007 14:08:54 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r575079 - in /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql: DB2Dictionary.java DBDictionary.java Date: Wed, 12 Sep 2007 21:08:54 -0000 To: commits@openjpa.apache.org From: fancy@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070912210854.70C471A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fancy Date: Wed Sep 12 14:08:53 2007 New Revision: 575079 URL: http://svn.apache.org/viewvc?rev=575079&view=rev Log: OPENJPA-360 FOR UPDATE clause incorrectly generated remove transient variable Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?rev=575079&r1=575078&r2=575079&view=diff ============================================================================== --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java (original) +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java Wed Sep 12 14:08:53 2007 @@ -313,12 +313,12 @@ * updateClause and isolationLevel hints */ protected String getForUpdateClause(JDBCFetchConfiguration fetch, - boolean isForUpdate) { + boolean isForUpdate, Select sel) { int isolationLevel; // For db2UDBV81OrEarlier and db2ISeriesV5R3OrEarlier: // "optimize for" clause appears before "for update" clause. StringBuffer forUpdateString = new StringBuffer( - getOptimizeClause(fetch)); + getOptimizeClause(sel)); try { // Determine the isolationLevel; the fetch // configuration data overrides the persistence.xml value @@ -464,7 +464,7 @@ } } - protected String getOptimizeClause(JDBCFetchConfiguration fetch) { + protected String getOptimizeClause(Select sel) { if (sel != null && sel.getExpectedResultCount() > 0) { StringBuffer buf = new StringBuffer(); buf.append(" ").append(optimizeClause).append(" ") Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=575079&r1=575078&r2=575079&view=diff ============================================================================== --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java (original) +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java Wed Sep 12 14:08:53 2007 @@ -60,7 +60,6 @@ import java.util.Locale; import java.util.Map; import java.util.Set; -import java.util.HashMap; import javax.sql.DataSource; import org.apache.commons.lang.StringUtils; @@ -70,8 +69,6 @@ import org.apache.openjpa.jdbc.kernel.exps.ExpContext; import org.apache.openjpa.jdbc.kernel.exps.ExpState; import org.apache.openjpa.jdbc.kernel.exps.FilterValue; -import org.apache.openjpa.jdbc.kernel.exps.Lit; -import org.apache.openjpa.jdbc.kernel.exps.Param; import org.apache.openjpa.jdbc.kernel.exps.Val; import org.apache.openjpa.jdbc.meta.ClassMapping; import org.apache.openjpa.jdbc.meta.FieldMapping; @@ -88,7 +85,6 @@ import org.apache.openjpa.jdbc.schema.Table; import org.apache.openjpa.jdbc.schema.Unique; import org.apache.openjpa.kernel.Filters; -import org.apache.openjpa.kernel.exps.Path; import org.apache.openjpa.lib.conf.Configurable; import org.apache.openjpa.lib.conf.Configuration; import org.apache.openjpa.lib.jdbc.ConnectionDecorator; @@ -325,7 +321,6 @@ private Method _setBytes = null; private Method _setString = null; private Method _setCharStream = null; - protected transient Select sel = null; public DBDictionary() { fixedSizeTypeNameSet.addAll(Arrays.asList(new String[]{ @@ -1989,7 +1984,6 @@ */ public SQLBuffer toSelect(Select sel, boolean forUpdate, JDBCFetchConfiguration fetch) { - this.sel = sel; sel.addJoinClassConditions(); boolean update = forUpdate && sel.getFromSelect() == null; SQLBuffer select = getSelects(sel, false, update); @@ -2004,7 +1998,7 @@ SQLBuffer where = getWhere(sel, update); return toSelect(select, fetch, from, where, sel.getGrouping(), sel.getHaving(), ordering, sel.isDistinct(), forUpdate, - sel.getStartIndex(), sel.getEndIndex()); + sel.getStartIndex(), sel.getEndIndex(), sel); } /** @@ -2192,7 +2186,20 @@ boolean distinct, boolean forUpdate, long start, long end) { return toOperation(getSelectOperation(fetch), selects, from, where, group, having, order, distinct, start, end, - getForUpdateClause(fetch, forUpdate)); + getForUpdateClause(fetch, forUpdate, null)); + } + + /** + * Combine the given components into a SELECT statement. + */ + public SQLBuffer toSelect(SQLBuffer selects, JDBCFetchConfiguration fetch, + SQLBuffer from, SQLBuffer where, SQLBuffer group, + SQLBuffer having, SQLBuffer order, + boolean distinct, boolean forUpdate, long start, long end + , Select sel) { + return toOperation(getSelectOperation(fetch), selects, from, where, + group, having, order, distinct, start, end, + getForUpdateClause(fetch, forUpdate, sel)); } /** @@ -2200,7 +2207,7 @@ * updateClause and isolationLevel hints */ protected String getForUpdateClause(JDBCFetchConfiguration fetch, - boolean isForUpdate) { + boolean isForUpdate, Select sel) { if (fetch != null && fetch.getIsolation() != -1) { throw new InvalidStateException(_loc.get( "isolation-level-config-not-supported", getClass().getName())); From commits-return-2374-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Wed Sep 12 21:12:19 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 24444 invoked from network); 12 Sep 2007 21:12:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Sep 2007 21:12:18 -0000 Received: (qmail 19936 invoked by uid 500); 12 Sep 2007 21:12:12 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 19918 invoked by uid 500); 12 Sep 2007 21:12:12 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 19909 invoked by uid 99); 12 Sep 2007 21:12:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Sep 2007 14:12:12 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Sep 2007 21:12:18 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E2D961A9832; Wed, 12 Sep 2007 14:11:57 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r575080 - in /openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql: DB2Dictionary.java DBDictionary.java Date: Wed, 12 Sep 2007 21:11:57 -0000 To: commits@openjpa.apache.org From: fancy@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070912211157.E2D961A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fancy Date: Wed Sep 12 14:11:56 2007 New Revision: 575080 URL: http://svn.apache.org/viewvc?rev=575080&view=rev Log: OPENJPA-360 FOR UPDATE clause incorrectly generated, remove transient variable declaration Modified: openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java Modified: openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?rev=575080&r1=575079&r2=575080&view=diff ============================================================================== --- openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java (original) +++ openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java Wed Sep 12 14:11:56 2007 @@ -286,12 +286,12 @@ * updateClause and isolationLevel hints */ protected String getForUpdateClause(JDBCFetchConfiguration fetch, - boolean isForUpdate) { + boolean isForUpdate, Select sel) { int isolationLevel; // For db2UDBV81OrEarlier and db2ISeriesV5R3OrEarlier: // "optimize for" clause appears before "for update" clause. StringBuffer forUpdateString = new StringBuffer( - getOptimizeClause(fetch)); + getOptimizeClause(sel)); try { // Determine the isolationLevel; the fetch // configuration data overrides the persistence.xml value @@ -437,7 +437,7 @@ } } - protected String getOptimizeClause(JDBCFetchConfiguration fetch) { + protected String getOptimizeClause(Select sel) { if (sel != null && sel.getExpectedResultCount() > 0) { StringBuffer buf = new StringBuffer(); buf.append(" ").append(optimizeClause).append(" ") Modified: openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=575080&r1=575079&r2=575080&view=diff ============================================================================== --- openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java (original) +++ openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java Wed Sep 12 14:11:56 2007 @@ -58,7 +58,6 @@ import java.util.Locale; import java.util.Map; import java.util.Set; -import java.util.HashMap; import javax.sql.DataSource; import org.apache.commons.lang.StringUtils; @@ -68,8 +67,6 @@ import org.apache.openjpa.jdbc.kernel.exps.ExpContext; import org.apache.openjpa.jdbc.kernel.exps.ExpState; import org.apache.openjpa.jdbc.kernel.exps.FilterValue; -import org.apache.openjpa.jdbc.kernel.exps.Lit; -import org.apache.openjpa.jdbc.kernel.exps.Param; import org.apache.openjpa.jdbc.kernel.exps.Val; import org.apache.openjpa.jdbc.meta.ClassMapping; import org.apache.openjpa.jdbc.meta.FieldMapping; @@ -86,7 +83,6 @@ import org.apache.openjpa.jdbc.schema.Table; import org.apache.openjpa.jdbc.schema.Unique; import org.apache.openjpa.kernel.Filters; -import org.apache.openjpa.kernel.exps.Path; import org.apache.openjpa.lib.conf.Configurable; import org.apache.openjpa.lib.conf.Configuration; import org.apache.openjpa.lib.jdbc.ConnectionDecorator; @@ -319,7 +315,6 @@ private Method _setBytes = null; private Method _setString = null; private Method _setCharStream = null; - protected transient Select sel = null; public DBDictionary() { fixedSizeTypeNameSet.addAll(Arrays.asList(new String[]{ @@ -1983,7 +1978,6 @@ */ public SQLBuffer toSelect(Select sel, boolean forUpdate, JDBCFetchConfiguration fetch) { - this.sel = sel; sel.addJoinClassConditions(); boolean update = forUpdate && sel.getFromSelect() == null; SQLBuffer select = getSelects(sel, false, update); @@ -1998,7 +1992,7 @@ SQLBuffer where = getWhere(sel, update); return toSelect(select, fetch, from, where, sel.getGrouping(), sel.getHaving(), ordering, sel.isDistinct(), forUpdate, - sel.getStartIndex(), sel.getEndIndex()); + sel.getStartIndex(), sel.getEndIndex(), sel); } /** @@ -2186,7 +2180,20 @@ boolean distinct, boolean forUpdate, long start, long end) { return toOperation(getSelectOperation(fetch), selects, from, where, group, having, order, distinct, start, end, - getForUpdateClause(fetch, forUpdate)); + getForUpdateClause(fetch, forUpdate, null)); + } + + /** + * Combine the given components into a SELECT statement. + */ + public SQLBuffer toSelect(SQLBuffer selects, JDBCFetchConfiguration fetch, + SQLBuffer from, SQLBuffer where, SQLBuffer group, + SQLBuffer having, SQLBuffer order, + boolean distinct, boolean forUpdate, long start, long end + , Select sel) { + return toOperation(getSelectOperation(fetch), selects, from, where, + group, having, order, distinct, start, end, + getForUpdateClause(fetch, forUpdate, sel)); } /** @@ -2194,7 +2201,7 @@ * updateClause and isolationLevel hints */ protected String getForUpdateClause(JDBCFetchConfiguration fetch, - boolean isForUpdate) { + boolean isForUpdate, Select sel) { if (fetch != null && fetch.getIsolation() != -1) { throw new InvalidStateException(_loc.get( "isolation-level-config-not-supported", getClass().getName())); From commits-return-2375-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Thu Sep 13 23:19:40 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 56148 invoked from network); 13 Sep 2007 23:19:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Sep 2007 23:19:40 -0000 Received: (qmail 16268 invoked by uid 500); 13 Sep 2007 23:19:32 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 16254 invoked by uid 500); 13 Sep 2007 23:19:32 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 16245 invoked by uid 99); 13 Sep 2007 23:19:32 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Sep 2007 16:19:32 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Sep 2007 23:21:19 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2AD621A9832; Thu, 13 Sep 2007 16:19:15 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r575492 - in /openjpa/branches/1.0.x: openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerFindField.java Date: Thu, 13 Sep 2007 23:19:14 -0000 To: commits@openjpa.apache.org From: pcl@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070913231915.2AD621A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pcl Date: Thu Sep 13 16:19:13 2007 New Revision: 575492 URL: http://svn.apache.org/viewvc?rev=575492&view=rev Log: OPENJPA-335 Added: openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerFindField.java Modified: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java Modified: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java?rev=575492&r1=575491&r2=575492&view=diff ============================================================================== --- openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java (original) +++ openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java Thu Sep 13 16:19:13 2007 @@ -696,8 +696,8 @@ BCField field = null, cur; Instruction templateIns, prevIns, earlierIns; - int backupCount = 3; while (code.searchForward(template)) { + int backupCount = 3; templateIns = code.previous(); if (!code.hasPrevious()) return null; Added: openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerFindField.java URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerFindField.java?rev=575492&view=auto ============================================================================== --- openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerFindField.java (added) +++ openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerFindField.java Thu Sep 13 16:19:13 2007 @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.enhance; + +import junit.framework.TestCase; +import serp.bytecode.BCClass; +import serp.bytecode.BCField; +import serp.bytecode.BCMethod; +import serp.bytecode.Project; + +public class TestPCEnhancerFindField + extends TestCase { + + private String field; + + public String myMethod() { + if (Math.abs(1) == 1) + return field; + else + return field; + } + + public void testPCEnhancerFindField() { + Project proj = new Project(); + BCClass bc = proj.loadClass(getClass()); + BCMethod meth = bc.getMethods("myMethod")[0]; + BCField field = PCEnhancer.getReturnedField(meth); + assertEquals("field", field.getName()); + } +} From commits-return-2376-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Thu Sep 13 23:24:34 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 58270 invoked from network); 13 Sep 2007 23:24:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Sep 2007 23:24:34 -0000 Received: (qmail 25955 invoked by uid 500); 13 Sep 2007 23:24:27 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 25932 invoked by uid 500); 13 Sep 2007 23:24:27 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 25923 invoked by uid 99); 13 Sep 2007 23:24:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Sep 2007 16:24:27 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Sep 2007 23:24:33 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 5C82F1A9832; Thu, 13 Sep 2007 16:24:13 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r575495 - in /openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerFindField.java Date: Thu, 13 Sep 2007 23:24:13 -0000 To: commits@openjpa.apache.org From: pcl@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070913232413.5C82F1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pcl Date: Thu Sep 13 16:24:12 2007 New Revision: 575495 URL: http://svn.apache.org/viewvc?rev=575495&view=rev Log: OPENJPA-335. 'svn merge -c 575492 ../branches/1.0.x' Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerFindField.java - copied unchanged from r575492, openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerFindField.java Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java?rev=575495&r1=575494&r2=575495&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java (original) +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java Thu Sep 13 16:24:12 2007 @@ -696,8 +696,8 @@ BCField field = null, cur; Instruction templateIns, prevIns, earlierIns; - int backupCount = 3; while (code.searchForward(template)) { + int backupCount = 3; templateIns = code.previous(); if (!code.hasPrevious()) return null; From commits-return-2377-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Fri Sep 14 16:33:36 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 6887 invoked from network); 14 Sep 2007 16:33:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Sep 2007 16:33:35 -0000 Received: (qmail 46718 invoked by uid 500); 14 Sep 2007 16:33:28 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 46704 invoked by uid 500); 14 Sep 2007 16:33:28 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 46695 invoked by uid 99); 14 Sep 2007 16:33:28 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Sep 2007 09:33:28 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Sep 2007 16:33:35 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6A9101A9832; Fri, 14 Sep 2007 09:33:14 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r575752 - /openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java Date: Fri, 14 Sep 2007 16:33:13 -0000 To: commits@openjpa.apache.org From: pcl@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070914163314.6A9101A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pcl Date: Fri Sep 14 09:33:09 2007 New Revision: 575752 URL: http://svn.apache.org/viewvc?rev=575752&view=rev Log: NPE check. Checking in on behalf of Abe. Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java?rev=575752&r1=575751&r2=575752&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java (original) +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java Fri Sep 14 09:33:09 2007 @@ -3666,7 +3666,7 @@ */ private String toBackingFieldName(String name) { if (_meta.getAccessType() == ClassMetaData.ACCESS_PROPERTY - && _attrsToFields.containsKey(name)) + && _attrsToFields != null && _attrsToFields.containsKey(name)) name = (String) _attrsToFields.get(name); return name; } @@ -3679,7 +3679,7 @@ // meta is null when doing persistence-aware enhancement if (_meta != null && _meta.getAccessType() == ClassMetaData.ACCESS_PROPERTY - && _fieldsToAttrs.containsKey(name)) + && _fieldsToAttrs != null && _fieldsToAttrs.containsKey(name)) return (String) _fieldsToAttrs.get(name); else return name; From commits-return-2378-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Mon Sep 17 18:13:11 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 53001 invoked from network); 17 Sep 2007 18:13:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Sep 2007 18:13:11 -0000 Received: (qmail 95108 invoked by uid 500); 17 Sep 2007 18:13:03 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 95096 invoked by uid 500); 17 Sep 2007 18:13:03 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 95087 invoked by uid 99); 17 Sep 2007 18:13:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Sep 2007 11:13:02 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Sep 2007 18:15:01 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B4B761A9832; Mon, 17 Sep 2007 11:12:47 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r576552 - /openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java Date: Mon, 17 Sep 2007 18:12:47 -0000 To: commits@openjpa.apache.org From: kwsutter@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070917181247.B4B761A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kwsutter Date: Mon Sep 17 11:12:46 2007 New Revision: 576552 URL: http://svn.apache.org/viewvc?rev=576552&view=rev Log: OPENJPA-367. Committing Albert's patch (since he doesn't have his committer karma quite yet...). Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java?rev=576552&r1=576551&r2=576552&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java (original) +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java Mon Sep 17 11:12:46 2007 @@ -4338,7 +4338,7 @@ log.trace(_loc.get("enhance-running", o)); if (o instanceof String) - bc = project.loadClass((String) o); + bc = project.loadClass((String) o, loader); else bc = project.loadClass((Class) o); enhancer = new PCEnhancer(conf, bc, repos, loader); From commits-return-2379-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Mon Sep 17 19:27:16 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 99562 invoked from network); 17 Sep 2007 19:27:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Sep 2007 19:27:15 -0000 Received: (qmail 7379 invoked by uid 500); 17 Sep 2007 19:27:08 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 7364 invoked by uid 500); 17 Sep 2007 19:27:08 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 7355 invoked by uid 99); 17 Sep 2007 19:27:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Sep 2007 12:27:07 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Sep 2007 19:29:06 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 249D91A9832; Mon, 17 Sep 2007 12:26:52 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r576564 - /openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java Date: Mon, 17 Sep 2007 19:26:51 -0000 To: commits@openjpa.apache.org From: kwsutter@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070917192652.249D91A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kwsutter Date: Mon Sep 17 12:26:51 2007 New Revision: 576564 URL: http://svn.apache.org/viewvc?rev=576564&view=rev Log: OPENJPA-367. Committing Albert's patch (since he doesn't have his committer karma quite yet...). Modified: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java Modified: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java?rev=576564&r1=576563&r2=576564&view=diff ============================================================================== --- openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java (original) +++ openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java Mon Sep 17 12:26:51 2007 @@ -4338,7 +4338,7 @@ log.trace(_loc.get("enhance-running", o)); if (o instanceof String) - bc = project.loadClass((String) o); + bc = project.loadClass((String) o, loader); else bc = project.loadClass((Class) o); enhancer = new PCEnhancer(conf, bc, repos, loader); From commits-return-2380-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Mon Sep 17 20:48:16 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 45050 invoked from network); 17 Sep 2007 20:48:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Sep 2007 20:48:16 -0000 Received: (qmail 18340 invoked by uid 500); 17 Sep 2007 20:48:08 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 18282 invoked by uid 500); 17 Sep 2007 20:48:08 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 18272 invoked by uid 99); 17 Sep 2007 20:48:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Sep 2007 13:48:08 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Sep 2007 20:50:07 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8E3E71A9832; Mon, 17 Sep 2007 13:47:53 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r576582 - /openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/JMSRemoteCommitProvider.java Date: Mon, 17 Sep 2007 20:47:53 -0000 To: commits@openjpa.apache.org From: ppoddar@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070917204753.8E3E71A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ppoddar Date: Mon Sep 17 13:47:52 2007 New Revision: 576582 URL: http://svn.apache.org/viewvc?rev=576582&view=rev Log: OPENJPA-24: Relaxing access to connect() for extensibility. Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/JMSRemoteCommitProvider.java Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/JMSRemoteCommitProvider.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/JMSRemoteCommitProvider.java?rev=576582&r1=576581&r2=576582&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/JMSRemoteCommitProvider.java (original) +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/JMSRemoteCommitProvider.java Mon Sep 17 13:47:52 2007 @@ -154,7 +154,7 @@ connect(); } - private void connect() { + protected void connect() { try { Context ctx = newContext(); TopicConnectionFactory tcf = From commits-return-2381-apmail-openjpa-commits-archive=openjpa.apache.org@openjpa.apache.org Tue Sep 18 14:03:36 2007 Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 55881 invoked from network); 18 Sep 2007 14:03:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Sep 2007 14:03:36 -0000 Received: (qmail 25900 invoked by uid 500); 18 Sep 2007 14:03:28 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 25889 invoked by uid 500); 18 Sep 2007 14:03:28 -0000 Mailing-List: contact commits-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 commits@openjpa.apache.org Received: (qmail 25880 invoked by uid 99); 18 Sep 2007 14:03:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Sep 2007 07:03:27 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Sep 2007 14:03:35 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id C73AD1A9832; Tue, 18 Sep 2007 07:03:14 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r576925 - /openjpa/trunk/openjpa-all/pom.xml Date: Tue, 18 Sep 2007 14:03:14 -0000 To: commits@openjpa.apache.org From: mikedd@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070918140314.C73AD1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mikedd Date: Tue Sep 18 07:03:14 2007 New Revision: 576925 URL: http://svn.apache.org/viewvc?rev=576925&view=rev Log: OPENJPA-364 commiting patch from David Jencks Modified: openjpa/trunk/openjpa-all/pom.xml Modified: openjpa/trunk/openjpa-all/pom.xml URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-all/pom.xml?rev=576925&r1=576924&r2=576925&view=diff ============================================================================== --- openjpa/trunk/openjpa-all/pom.xml (original) +++ openjpa/trunk/openjpa-all/pom.xml Tue Sep 18 07:03:14 2007 @@ -80,48 +80,6 @@ - - - org.apache.openjpa - openjpa-lib - ${pom.version} - - - org.apache.openjpa - openjpa-kernel - ${pom.version} - - - org.apache.openjpa - openjpa-kernel-5 - ${pom.version} - - - org.apache.openjpa - openjpa-jdbc - ${pom.version} - - - org.apache.openjpa - openjpa-jdbc-5 - ${pom.version} - - - org.apache.openjpa - openjpa-persistence - ${pom.version} - - - org.apache.openjpa - openjpa-persistence-jdbc - ${pom.version} - - - org.apache.openjpa - openjpa-xmlstore - ${pom.version} - - + + 4.0.0 + org.apache.openjpa + openjpa-lib-5 + jar + OpenJPA Utilities 1.5 + OpenJPA Utilities 1.5 + http://openjpa.apache.org + + org.apache.openjpa + openjpa-parent + 1.1.0-SNAPSHOT + + + + org.apache.openjpa + openjpa-lib + ${pom.version} + compile + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + + Added: openjpa/trunk/openjpa-lib-5/src/main/java/org/apache/openjpa/lib/util/J2DoPriv5Helper.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib-5/src/main/java/org/apache/openjpa/lib/util/J2DoPriv5Helper.java?rev=580451&view=auto ============================================================================== --- openjpa/trunk/openjpa-lib-5/src/main/java/org/apache/openjpa/lib/util/J2DoPriv5Helper.java (added) +++ openjpa/trunk/openjpa-lib-5/src/main/java/org/apache/openjpa/lib/util/J2DoPriv5Helper.java Fri Sep 28 11:23:48 2007 @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.lib.util; + +import java.lang.reflect.AnnotatedElement; +import java.security.PrivilegedAction; + +/** + * Helper class to obtain the Privilege(Exception)Action object to perform + * Java 2 doPrivilege security sensitive function call in the following + * methods: + *
    + *
  • AnnotatedElement.getAnnotations + *
  • AnnotatedElement.getDeclaredAnnotations + *
  • AnnotatedElement.isAnnotationPresent + *
+ * + * @author Albert Lee + */ + +public abstract class J2DoPriv5Helper extends J2DoPrivHelper { + + /** + * Return a PrivilegeAction object for AnnotatedElement.getAnnotations(). + * + * Requires security policy: + * 'permission java.lang.RuntimePermission "accessDeclaredMembers";' + * + * @return Annotation[] + */ + public static final PrivilegedAction getAnnotationsAction( + final AnnotatedElement element) { + return new PrivilegedAction() { + public Object run() { + return element.getAnnotations(); + } + }; + } + + /** + * Return a PrivilegeAction object for + * AnnotatedElement.getDeclaredAnnotations(). + * + * Requires security policy: + * 'permission java.lang.RuntimePermission "accessDeclaredMembers";' + * + * @return Annotation[] + */ + public static final PrivilegedAction getDeclaredAnnotationsAction( + final AnnotatedElement element) { + return new PrivilegedAction() { + public Object run() { + return element.getDeclaredAnnotations(); + } + }; + } + + /** + * Return a PrivilegeAction object for + * AnnotatedElement.isAnnotationPresent(). + * + * Requires security policy: + * 'permission java.lang.RuntimePermission "accessDeclaredMembers";' + * + * @return Boolean + */ + public static final PrivilegedAction isAnnotationPresentAction( + final AnnotatedElement element, final Class annotationClazz) { + return new PrivilegedAction() { + public Object run() { + return element.isAnnotationPresent(annotationClazz) + ? Boolean.TRUE : Boolean.FALSE; + } + }; + } +} Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/J2DoPrivHelper.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/J2DoPrivHelper.java?rev=580451&r1=580450&r2=580451&view=diff ============================================================================== --- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/J2DoPrivHelper.java (original) +++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/J2DoPrivHelper.java Fri Sep 28 11:23:48 2007 @@ -24,7 +24,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.lang.reflect.AccessibleObject; -import java.lang.reflect.AnnotatedElement; import java.net.InetAddress; import java.net.MalformedURLException; import java.net.ServerSocket; @@ -49,9 +48,6 @@ * methods: *
    *
  • AccessibleObject.setAccessible - *
  • AnnotatedElement.getAnnotations - *
  • AnnotatedElement.getDeclaredAnnotations - *
  • AnnotatedElement.isAnnotationPresent *
  • Class.forName *
  • Class.getClassLoader *
  • Class.getDeclaredField @@ -324,60 +320,6 @@ return new PrivilegedAction() { public Object run() { return clazz.getResource(resource); - } - }; - } - - /** - * Return a PrivilegeAction object for AnnotatedElement.getAnnotations(). - * - * Requires security policy: - * 'permission java.lang.RuntimePermission "accessDeclaredMembers";' - * - * @return Annotation[] - */ - public static final PrivilegedAction getAnnotationsAction( - final AnnotatedElement element) { - return new PrivilegedAction() { - public Object run() { - return element.getAnnotations(); - } - }; - } - - /** - * Return a PrivilegeAction object for - * AnnotatedElement.getDeclaredAnnotations(). - * - * Requires security policy: - * 'permission java.lang.RuntimePermission "accessDeclaredMembers";' - * - * @return Annotation[] - */ - public static final PrivilegedAction getDeclaredAnnotationsAction( - final AnnotatedElement element) { - return new PrivilegedAction() { - public Object run() { - return element.getDeclaredAnnotations(); - } - }; - } - - /** - * Return a PrivilegeAction object for - * AnnotatedElement.isAnnotationPresent(). - * - * Requires security policy: - * 'permission java.lang.RuntimePermission "accessDeclaredMembers";' - * - * @return Boolean - */ - public static final PrivilegedAction isAnnotationPresentAction( - final AnnotatedElement element, final Class annotationClazz) { - return new PrivilegedAction() { - public Object run() { - return element.isAnnotationPresent(annotationClazz) - ? Boolean.TRUE : Boolean.FALSE; } }; } Modified: openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java?rev=580451&r1=580450&r2=580451&view=diff ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java (original) +++ openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java Fri Sep 28 11:23:48 2007 @@ -75,7 +75,7 @@ import org.apache.openjpa.jdbc.schema.Unique; import org.apache.openjpa.jdbc.sql.DBDictionary; import org.apache.openjpa.lib.log.Log; -import org.apache.openjpa.lib.util.J2DoPrivHelper; +import org.apache.openjpa.lib.util.J2DoPriv5Helper; import org.apache.openjpa.lib.util.Localizer; import org.apache.openjpa.meta.ClassMetaData; import org.apache.openjpa.meta.FieldMetaData; @@ -1060,7 +1060,7 @@ if (xmlTypeClass != null && StringUtils.isEmpty(pcols[i].columnDefinition()) - && ((Boolean) AccessController.doPrivileged(J2DoPrivHelper + && ((Boolean) AccessController.doPrivileged(J2DoPriv5Helper .isAnnotationPresentAction(fm.getDeclaredType(), xmlTypeClass))).booleanValue()) { DBDictionary dict = ((MappingRepository) getRepository()) Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java?rev=580451&r1=580450&r2=580451&view=diff ============================================================================== --- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java (original) +++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java Fri Sep 28 11:23:48 2007 @@ -87,7 +87,7 @@ import org.apache.openjpa.kernel.jpql.JPQLParser; import org.apache.openjpa.lib.conf.Configurations; import org.apache.openjpa.lib.log.Log; -import org.apache.openjpa.lib.util.J2DoPrivHelper; +import org.apache.openjpa.lib.util.J2DoPriv5Helper; import org.apache.openjpa.lib.util.Localizer; import org.apache.openjpa.meta.ClassMetaData; import org.apache.openjpa.meta.DelegatingMetaDataFactory; @@ -465,12 +465,12 @@ // check immediately whether the user is using any annotations, // regardless of mode. this prevents adding non-entity classes to // repository if we're ignoring these annotations in mapping mode - if (!((Boolean) AccessController.doPrivileged(J2DoPrivHelper + if (!((Boolean) AccessController.doPrivileged(J2DoPriv5Helper .isAnnotationPresentAction(_cls, Entity.class))).booleanValue() - && !((Boolean) AccessController.doPrivileged(J2DoPrivHelper + && !((Boolean) AccessController.doPrivileged(J2DoPriv5Helper .isAnnotationPresentAction(_cls, Embeddable.class))) .booleanValue() - && !((Boolean) AccessController.doPrivileged(J2DoPrivHelper + && !((Boolean) AccessController.doPrivileged(J2DoPriv5Helper .isAnnotationPresentAction(_cls, MappedSuperclass.class))) .booleanValue()) return null; @@ -669,17 +669,17 @@ String rsrc = StringUtils.replace(cls.getName(), ".", "/"); ClassLoader loader = (ClassLoader) AccessController.doPrivileged( - J2DoPrivHelper.getClassLoaderAction(cls)); + J2DoPriv5Helper.getClassLoaderAction(cls)); if (loader == null) loader = (ClassLoader) AccessController.doPrivileged( - J2DoPrivHelper.getSystemClassLoaderAction()); + J2DoPriv5Helper.getSystemClassLoaderAction()); if (loader == null) return null; URL url = (URL) AccessController.doPrivileged( - J2DoPrivHelper.getResourceAction(loader, rsrc + ".java")); + J2DoPriv5Helper.getResourceAction(loader, rsrc + ".java")); if (url == null) { url = (URL) AccessController.doPrivileged( - J2DoPrivHelper.getResourceAction(loader, rsrc + ".class")); + J2DoPriv5Helper.getResourceAction(loader, rsrc + ".class")); if (url == null) return null; } @@ -764,10 +764,10 @@ meta.setDetachedState(detached.fieldName()); } else { Field[] fields = (Field[]) AccessController.doPrivileged( - J2DoPrivHelper.getDeclaredFieldsAction( + J2DoPriv5Helper.getDeclaredFieldsAction( meta.getDescribedType())); for (int i = 0; i < fields.length; i++) - if (((Boolean) AccessController.doPrivileged(J2DoPrivHelper + if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper .isAnnotationPresentAction(fields[i], DetachedState.class))) .booleanValue()) meta.setDetachedState(fields[i].getName()); @@ -808,7 +808,7 @@ Set seen = new HashSet(); do { for (Method m : (Method[]) AccessController.doPrivileged( - J2DoPrivHelper.getDeclaredMethodsAction(sup))) { + J2DoPriv5Helper.getDeclaredMethodsAction(sup))) { mods = m.getModifiers(); if (Modifier.isStatic(mods) || Modifier.isFinal(mods) || Object.class.equals(m.getDeclaringClass())) @@ -826,7 +826,8 @@ MetaDataDefaults def = repos.getMetaDataFactory().getDefaults(); for (Method m : methods) { for (Annotation anno : (Annotation[]) AccessController - .doPrivileged(J2DoPrivHelper.getDeclaredAnnotationsAction(m))) { + .doPrivileged(J2DoPriv5Helper + .getDeclaredAnnotationsAction(m))) { MetaDataTag tag = _tags.get(anno.annotationType()); if (tag == null) continue; @@ -964,7 +965,7 @@ fmd.setExplicit(true); AnnotatedElement el = (AnnotatedElement) member; - boolean lob = ((Boolean) AccessController.doPrivileged(J2DoPrivHelper + boolean lob = ((Boolean) AccessController.doPrivileged(J2DoPriv5Helper .isAnnotationPresentAction(el, Lob.class))).booleanValue(); if (isMetaDataMode()) { switch (pstrat) { Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceXMLMetaDataParser.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceXMLMetaDataParser.java?rev=580451&r1=580450&r2=580451&view=diff ============================================================================== --- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceXMLMetaDataParser.java (original) +++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceXMLMetaDataParser.java Fri Sep 28 11:23:48 2007 @@ -27,7 +27,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.openjpa.conf.OpenJPAConfiguration; import org.apache.openjpa.lib.log.Log; -import org.apache.openjpa.lib.util.J2DoPrivHelper; +import org.apache.openjpa.lib.util.J2DoPriv5Helper; import org.apache.openjpa.lib.util.Localizer; import org.apache.openjpa.meta.DelegatingMetaDataFactory; import org.apache.openjpa.meta.FieldMetaData; @@ -173,10 +173,10 @@ private XMLMetaData parseXMLClassAnnotations() { // check immediately whether the class has JAXB XML annotations if (_cls == null || xmlTypeClass == null - || !(((Boolean) AccessController.doPrivileged(J2DoPrivHelper + || !(((Boolean) AccessController.doPrivileged(J2DoPriv5Helper .isAnnotationPresentAction(_cls, xmlTypeClass))).booleanValue() && ((Boolean) AccessController - .doPrivileged(J2DoPrivHelper.isAnnotationPresentAction(_cls, + .doPrivileged(J2DoPriv5Helper.isAnnotationPresentAction(_cls, xmlRootElementClass))).booleanValue())) return null; @@ -225,7 +225,7 @@ Class superclass = cls.getSuperclass(); // handle inheritance at sub-element level - if (((Boolean) AccessController.doPrivileged(J2DoPrivHelper + if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper .isAnnotationPresentAction(superclass, xmlTypeClass))) .booleanValue()) populateFromReflection(superclass, meta); @@ -247,7 +247,7 @@ // avoid JAXB XML bind default name if (StringUtils.equals(XMLMetaData.defaultName, xmlname)) xmlname = member.getName(); - if (((Boolean) AccessController.doPrivileged(J2DoPrivHelper + if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper .isAnnotationPresentAction(((Field) member).getType(), xmlTypeClass))).booleanValue()) { field = _repos.addXMLMetaData(((Field) member).getType() Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataDefaults.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataDefaults.java?rev=580451&r1=580450&r2=580451&view=diff ============================================================================== --- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataDefaults.java (original) +++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataDefaults.java Fri Sep 28 11:23:48 2007 @@ -48,7 +48,7 @@ import javax.persistence.Transient; import org.apache.commons.lang.StringUtils; -import org.apache.openjpa.lib.util.J2DoPrivHelper; +import org.apache.openjpa.lib.util.J2DoPriv5Helper; import org.apache.openjpa.lib.util.Localizer; import org.apache.openjpa.lib.log.Log; import org.apache.openjpa.meta.AbstractMetaDataDefaults; @@ -116,7 +116,7 @@ if (member == null) return null; AnnotatedElement el = (AnnotatedElement) member; - if (((Boolean) AccessController.doPrivileged(J2DoPrivHelper + if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper .isAnnotationPresentAction(el, Transient.class))).booleanValue()) return TRANSIENT; if (fmd != null @@ -183,7 +183,7 @@ } //### EJB3: what if defined in XML? - if (((Boolean) AccessController.doPrivileged(J2DoPrivHelper + if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper .isAnnotationPresentAction(type, Embeddable.class))).booleanValue()) return EMBEDDED; if (Serializable.class.isAssignableFrom(type)) @@ -258,10 +258,10 @@ int access = 0; if (usesAccess((Field[]) AccessController.doPrivileged( - J2DoPrivHelper.getDeclaredFieldsAction(cls)))) + J2DoPriv5Helper.getDeclaredFieldsAction(cls)))) access |= ClassMetaData.ACCESS_FIELD; if (usesAccess((Method[]) AccessController.doPrivileged( - J2DoPrivHelper.getDeclaredMethodsAction(cls)))) + J2DoPriv5Helper.getDeclaredMethodsAction(cls)))) access |= ClassMetaData.ACCESS_PROPERTY; return (access == 0) ? getAccessType(cls.getSuperclass()) : access; } @@ -273,7 +273,7 @@ Annotation[] annos; String name; for (int i = 0; i < members.length; i++) { - annos = (Annotation[]) AccessController.doPrivileged(J2DoPrivHelper + annos = (Annotation[]) AccessController.doPrivileged(J2DoPriv5Helper .getAnnotationsAction(members[i])); for (int j = 0; j < annos.length; j++) { name = annos[j].annotationType().getName(); @@ -296,7 +296,7 @@ try { // check for setters for methods Method setter = (Method) AccessController.doPrivileged( - J2DoPrivHelper.getDeclaredMethodAction( + J2DoPriv5Helper.getDeclaredMethodAction( meta.getDescribedType(), "set" + StringUtils.capitalize(name), new Class[] { ((Method) member).getReturnType() })); @@ -320,7 +320,7 @@ private boolean isAnnotatedTransient(Member member) { return member instanceof AnnotatedElement - && ((Boolean) AccessController.doPrivileged(J2DoPrivHelper + && ((Boolean) AccessController.doPrivileged(J2DoPriv5Helper .isAnnotationPresentAction(((AnnotatedElement) member), Transient.class))).booleanValue(); } Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java?rev=580451&r1=580450&r2=580451&view=diff ============================================================================== --- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java (original) +++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java Fri Sep 28 11:23:48 2007 @@ -32,10 +32,10 @@ import javax.persistence.Embeddable; import javax.persistence.Entity; import javax.persistence.MappedSuperclass; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; import javax.persistence.NamedNativeQueries; import javax.persistence.NamedNativeQuery; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; import javax.persistence.SqlResultSetMapping; import javax.persistence.SqlResultSetMappings; @@ -46,7 +46,7 @@ import org.apache.openjpa.lib.meta.ClassArgParser; import org.apache.openjpa.lib.meta.MetaDataFilter; import org.apache.openjpa.lib.meta.MetaDataParser; -import org.apache.openjpa.lib.util.J2DoPrivHelper; +import org.apache.openjpa.lib.util.J2DoPriv5Helper; import org.apache.openjpa.lib.util.Localizer; import org.apache.openjpa.lib.util.Options; import org.apache.openjpa.meta.AbstractCFMetaDataFactory; @@ -293,24 +293,24 @@ return null; Collection classes = repos.loadPersistentTypes(false, loader); for (Class cls : (Collection) classes) { - if (((Boolean) AccessController.doPrivileged(J2DoPrivHelper + if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper .isAnnotationPresentAction(cls, NamedQuery.class))) .booleanValue() && hasNamedQuery (queryName, (NamedQuery) cls.getAnnotation(NamedQuery.class))) return cls; - if (((Boolean) AccessController.doPrivileged(J2DoPrivHelper + if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper .isAnnotationPresentAction(cls, NamedQueries.class))) .booleanValue() && hasNamedQuery(queryName, ((NamedQueries) cls. getAnnotation(NamedQueries.class)).value())) return cls; - if (((Boolean) AccessController.doPrivileged(J2DoPrivHelper + if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper .isAnnotationPresentAction(cls, NamedNativeQuery.class))) .booleanValue() && hasNamedNativeQuery(queryName, (NamedNativeQuery) cls. getAnnotation(NamedNativeQuery.class))) return cls; - if (((Boolean) AccessController.doPrivileged(J2DoPrivHelper + if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper .isAnnotationPresentAction(cls, NamedNativeQueries.class))) .booleanValue() && hasNamedNativeQuery(queryName, ((NamedNativeQueries) cls. @@ -329,14 +329,14 @@ Collection classes = repos.loadPersistentTypes(false, loader); for (Class cls : (Collection) classes) { - if (((Boolean) AccessController.doPrivileged(J2DoPrivHelper + if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper .isAnnotationPresentAction(cls, SqlResultSetMapping.class))) .booleanValue() && hasRSMapping(rsMappingName, (SqlResultSetMapping) cls. getAnnotation(SqlResultSetMapping.class))) return cls; - if (((Boolean) AccessController.doPrivileged(J2DoPrivHelper + if (((Boolean) AccessController.doPrivileged(J2DoPriv5Helper .isAnnotationPresentAction(cls, SqlResultSetMappings.class))) .booleanValue() && hasRSMapping(rsMappingName, ((SqlResultSetMappings) cls. @@ -458,11 +458,11 @@ ClassLoader loader = repos.getConfiguration(). getClassResolverInstance().getClassLoader(getClass(), null); URL rsrc = (URL) AccessController.doPrivileged( - J2DoPrivHelper.getResourceAction(loader, "META-INF/orm.xml")); + J2DoPriv5Helper.getResourceAction(loader, "META-INF/orm.xml")); if (rsrc != null) { File file = new File(rsrc.getFile()); if (((Boolean) AccessController.doPrivileged( - J2DoPrivHelper.existsAction(file))).booleanValue()) + J2DoPriv5Helper.existsAction(file))).booleanValue()) return file; } return new File("orm.xml"); Modified: openjpa/trunk/pom.xml URL: http://svn.apache.org/viewvc/openjpa/trunk/pom.xml?rev=580451&r1=580450&r2=580451&view=diff ============================================================================== --- openjpa/trunk/pom.xml (original) +++ openjpa/trunk/pom.xml Fri Sep 28 11:23:48 2007 @@ -96,6 +96,7 @@ 1.5 + openjpa-lib-5 openjpa-persistence openjpa-persistence-jdbc openjpa-kernel-5