Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 30463 invoked from network); 9 Mar 2011 15:49:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 9 Mar 2011 15:49:44 -0000 Received: (qmail 81423 invoked by uid 500); 9 Mar 2011 15:49:44 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 81395 invoked by uid 500); 9 Mar 2011 15:49:43 -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 81388 invoked by uid 99); 9 Mar 2011 15:49:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Mar 2011 15:49:43 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Mar 2011 15:49:42 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BD9CB2388A3F; Wed, 9 Mar 2011 15:49:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1079853 - in /openjpa/branches/2.1.x: openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/ openjpa-persistence-jdbc/src/test/java/org/apac... Date: Wed, 09 Mar 2011 15:49:21 -0000 To: commits@openjpa.apache.org From: mikedd@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110309154921.BD9CB2388A3F@eris.apache.org> Author: mikedd Date: Wed Mar 9 15:49:21 2011 New Revision: 1079853 URL: http://svn.apache.org/viewvc?rev=1079853&view=rev Log: OPENJPA-1957: treat non element collection like normal serializable types Added: openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/ openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/TestAnnoExceptionEntity.java (with props) openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/TestXMLExceptionEntity.java (with props) openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/model/ openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/model/AnnoExceptionEntity.java (with props) openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/model/XMLExceptionEntity.java (with props) openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/resources/META-INF/arrays-orm.xml (with props) Modified: openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml openjpa/branches/2.1.x/openjpa-project/checkstyle.xml Modified: openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java?rev=1079853&r1=1079852&r2=1079853&view=diff ============================================================================== --- openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java (original) +++ openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/XMLPersistenceMappingParser.java Wed Mar 9 15:49:21 2011 @@ -678,6 +678,12 @@ public class XMLPersistenceMappingParser } // else no break case JavaTypes.COLLECTION: + if(fm.isElementCollection()) { + fm.getElementMapping().getValueInfo().setColumns(_cols); + } else { + fm.getValueInfo().setColumns(_cols); + } + break; case JavaTypes.MAP: fm.getElementMapping().getValueInfo().setColumns(_cols); break; Added: openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/TestAnnoExceptionEntity.java URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/TestAnnoExceptionEntity.java?rev=1079853&view=auto ============================================================================== --- openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/TestAnnoExceptionEntity.java (added) +++ openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/TestAnnoExceptionEntity.java Wed Mar 9 15:49:21 2011 @@ -0,0 +1,115 @@ +/* + * 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.persistence.arrays; + +import java.util.ArrayList; + +import javax.persistence.EntityManager; + +import org.apache.openjpa.persistence.arrays.model.AnnoExceptionEntity; +import org.apache.openjpa.persistence.test.SingleEMFTestCase; + +public class TestAnnoExceptionEntity extends SingleEMFTestCase { + + public void setUp() { + super.setUp(AnnoExceptionEntity.class); + } + + public void testExceptionArrayAsLob() { + EntityManager em = emf.createEntityManager(); + em.getTransaction().begin(); + + AnnoExceptionEntity e = new AnnoExceptionEntity(); + e.setId(1); + em.persist(e); + e.setExceptions(new ArrayList()); + e.getExceptions().add(new Exception("Exception 1")); + e.getExceptions().add(new Exception("Exception 2")); + em.getTransaction().commit(); + + em.clear(); + e = em.find(AnnoExceptionEntity.class, 1); + + assertNotNull(e); + assertNotNull(e.getExceptions()); + assertEquals(2, e.getExceptions().size()); + // we don't really care about ordering for this example. + + em.getTransaction().begin(); + em.remove(e); + em.getTransaction().commit(); + + em.close(); + } + + public void testExceptionPersistentCollection() { + EntityManager em = emf.createEntityManager(); + em.getTransaction().begin(); + + AnnoExceptionEntity e = new AnnoExceptionEntity(); + e.setId(1); + em.persist(e); + e.setPersCollExceptions(new ArrayList()); + e.getPersCollExceptions().add(new Exception("Exception 1")); + e.getPersCollExceptions().add(new Exception("Exception 2")); + em.getTransaction().commit(); + + em.clear(); + e = em.find(AnnoExceptionEntity.class, 1); + + assertNotNull(e); + assertNotNull(e.getPersCollExceptions()); + assertEquals(2, e.getPersCollExceptions().size()); + // we don't really care about ordering for this example. + + em.getTransaction().begin(); + em.remove(e); + em.getTransaction().commit(); + + em.close(); + } + + public void testExceptionElementCollection() { + EntityManager em = emf.createEntityManager(); + em.getTransaction().begin(); + + AnnoExceptionEntity e = new AnnoExceptionEntity(); + e.setId(1); + em.persist(e); + e.setElemCollExceptions(new ArrayList()); + e.getElemCollExceptions().add(new Exception("Exception 1").toString()); + e.getElemCollExceptions().add(new Exception("Exception 2").toString()); + em.getTransaction().commit(); + + em.clear(); + e = em.find(AnnoExceptionEntity.class, 1); + + assertNotNull(e); + assertNotNull(e.getElemCollExceptions()); + assertEquals(2, e.getElemCollExceptions().size()); + // we don't really care about ordering for this example. + + em.getTransaction().begin(); + em.remove(e); + em.getTransaction().commit(); + + em.close(); + } + +} Propchange: openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/TestAnnoExceptionEntity.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/TestXMLExceptionEntity.java URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/TestXMLExceptionEntity.java?rev=1079853&view=auto ============================================================================== --- openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/TestXMLExceptionEntity.java (added) +++ openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/TestXMLExceptionEntity.java Wed Mar 9 15:49:21 2011 @@ -0,0 +1,116 @@ +/* + * 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.persistence.arrays; + +import java.util.ArrayList; + +import javax.persistence.EntityManager; + +import org.apache.openjpa.persistence.arrays.model.XMLExceptionEntity; +import org.apache.openjpa.persistence.test.SingleEMFTestCase; + +public class TestXMLExceptionEntity extends SingleEMFTestCase { + + @Override + protected String getPersistenceUnitName() { + return "arrays"; + } + + public void testExceptionArrayAsLob() { + EntityManager em = emf.createEntityManager(); + em.getTransaction().begin(); + + XMLExceptionEntity e = new XMLExceptionEntity(); + e.setId(1); + em.persist(e); + e.setExceptions(new ArrayList()); + e.getExceptions().add(new Exception("Exception 1")); + e.getExceptions().add(new Exception("Exception 2")); + em.getTransaction().commit(); + + em.clear(); + e = em.find(XMLExceptionEntity.class, 1); + + assertNotNull(e); + assertNotNull(e.getExceptions()); + assertEquals(2, e.getExceptions().size()); + // we don't really care about ordering for this example. + + em.getTransaction().begin(); + em.remove(e); + em.getTransaction().commit(); + + em.close(); + } + + public void testExceptionPersistentCollection() { + EntityManager em = emf.createEntityManager(); + em.getTransaction().begin(); + + XMLExceptionEntity e = new XMLExceptionEntity(); + e.setId(1); + em.persist(e); + e.setPersCollExceptions(new ArrayList()); + e.getPersCollExceptions().add(new Exception("Exception 1")); + e.getPersCollExceptions().add(new Exception("Exception 2")); + em.getTransaction().commit(); + + em.clear(); + e = em.find(XMLExceptionEntity.class, 1); + + assertNotNull(e); + assertNotNull(e.getPersCollExceptions()); + assertEquals(2, e.getPersCollExceptions().size()); + // we don't really care about ordering for this example. + + em.getTransaction().begin(); + em.remove(e); + em.getTransaction().commit(); + + em.close(); + } + + public void testExceptionElementCollection() { + EntityManager em = emf.createEntityManager(); + em.getTransaction().begin(); + + XMLExceptionEntity e = new XMLExceptionEntity(); + e.setId(1); + em.persist(e); + e.setElemCollExceptions(new ArrayList()); + e.getElemCollExceptions().add(new Exception("Exception 1").toString()); + e.getElemCollExceptions().add(new Exception("Exception 2").toString()); + em.getTransaction().commit(); + + em.clear(); + e = em.find(XMLExceptionEntity.class, 1); + + assertNotNull(e); + assertNotNull(e.getElemCollExceptions()); + assertEquals(2, e.getElemCollExceptions().size()); + // we don't really care about ordering for this example. + + em.getTransaction().begin(); + em.remove(e); + em.getTransaction().commit(); + + em.close(); + } + +} Propchange: openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/TestXMLExceptionEntity.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/model/AnnoExceptionEntity.java URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/model/AnnoExceptionEntity.java?rev=1079853&view=auto ============================================================================== --- openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/model/AnnoExceptionEntity.java (added) +++ openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/model/AnnoExceptionEntity.java Wed Mar 9 15:49:21 2011 @@ -0,0 +1,83 @@ +/* + * 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.persistence.arrays.model; + +import java.util.ArrayList; +import java.util.Collection; + +import javax.persistence.ElementCollection; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Lob; +import javax.persistence.Table; + +import org.apache.openjpa.persistence.PersistentCollection; + +/** + * Entity of questionable real-world value. Intended to test the ability to persist an array of serializable types (in + * this case exceptions) as a Lob. + */ +@Entity +@Table(name = "ANN_EX_ENTITY") +public class AnnoExceptionEntity { + @Id + private int id; + + @Lob + private ArrayList exceptions; + + // ElementCollection does not work with exceptions. + @ElementCollection + private Collection elemCollExceptions; + + @PersistentCollection + private Collection persCollExceptions; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public ArrayList getExceptions() { + return exceptions; + } + + public void setExceptions(ArrayList exceptions) { + this.exceptions = exceptions; + } + + public Collection getElemCollExceptions() { + return elemCollExceptions; + } + + public void setElemCollExceptions(Collection elemCollExceptions) { + this.elemCollExceptions = elemCollExceptions; + } + + public Collection getPersCollExceptions() { + return persCollExceptions; + } + + public void setPersCollExceptions(Collection persCollExceptions) { + this.persCollExceptions = persCollExceptions; + } +} Propchange: openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/model/AnnoExceptionEntity.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/model/XMLExceptionEntity.java URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/model/XMLExceptionEntity.java?rev=1079853&view=auto ============================================================================== --- openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/model/XMLExceptionEntity.java (added) +++ openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/model/XMLExceptionEntity.java Wed Mar 9 15:49:21 2011 @@ -0,0 +1,68 @@ +/* + * 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.persistence.arrays.model; + +import java.util.ArrayList; + +/** + * Entity of questionable real-world value. Intended to test the ability to persist an array of serializable types (in + * this case exceptions) as a Lob. + */ +public class XMLExceptionEntity { + private int id; + + private ArrayList exceptions; + + // Element collection does not work with Exceptions + private ArrayList elemCollExceptions; + + private ArrayList persCollExceptions; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public ArrayList getExceptions() { + return exceptions; + } + + public void setExceptions(ArrayList exceptions) { + this.exceptions = exceptions; + } + + public ArrayList getElemCollExceptions() { + return elemCollExceptions; + } + + public void setElemCollExceptions(ArrayList elemCollExceptions) { + this.elemCollExceptions = elemCollExceptions; + } + + public ArrayList getPersCollExceptions() { + return persCollExceptions; + } + + public void setPersCollExceptions(ArrayList persCollExceptions) { + this.persCollExceptions = persCollExceptions; + } +} Propchange: openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/arrays/model/XMLExceptionEntity.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/resources/META-INF/arrays-orm.xml URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/resources/META-INF/arrays-orm.xml?rev=1079853&view=auto ============================================================================== --- openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/resources/META-INF/arrays-orm.xml (added) +++ openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/resources/META-INF/arrays-orm.xml Wed Mar 9 15:49:21 2011 @@ -0,0 +1,21 @@ + + + + + + + + + + + + + Propchange: openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/resources/META-INF/arrays-orm.xml ------------------------------------------------------------------------------ svn:eol-style = native Modified: openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml?rev=1079853&r1=1079852&r2=1079853&view=diff ============================================================================== --- openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml (original) +++ openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml Wed Mar 9 15:49:21 2011 @@ -54,7 +54,7 @@ org/apache/openjpa/persistence/detach/detach-orm.xml org/apache/openjpa/persistence/enhance/identity/mapsId-orm.xml org/apache/openjpa/persistence/entity/orm.xml - + META-INF/arrays-orm.xml @@ -378,5 +378,11 @@ + + + META-INF/arrays-orm.xml + + + Modified: openjpa/branches/2.1.x/openjpa-project/checkstyle.xml URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-project/checkstyle.xml?rev=1079853&r1=1079852&r2=1079853&view=diff ============================================================================== --- openjpa/branches/2.1.x/openjpa-project/checkstyle.xml (original) +++ openjpa/branches/2.1.x/openjpa-project/checkstyle.xml Wed Mar 9 15:49:21 2011 @@ -28,7 +28,6 @@ pom.xml --> -