openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r532805 - in /incubator/openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ openjpa-kernel/src/main/java/org/apache/openjpa/meta/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/ openjpa...
Date Thu, 26 Apr 2007 17:17:12 GMT
Author: pcl
Date: Thu Apr 26 10:17:10 2007
New Revision: 532805

URL: http://svn.apache.org/viewvc?view=rev&rev=532805
Log:
OPENJPA-229

Added:
    incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/TestSharedUnqualifiedClassNames.java
    incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/embeddable/
    incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/entity/
    incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/mappedsuperclass/
Modified:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java?view=diff&rev=532805&r1=532804&r2=532805
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
Thu Apr 26 10:17:10 2007
@@ -2283,7 +2283,12 @@
         code.getstatic().setField(PRE + "FieldTypes", Class[].class);
         code.getstatic().setField(PRE + "FieldFlags", byte[].class);
         code.getstatic().setField(SUPER, Class.class);
-        code.constant().setValue(_meta.getTypeAlias());
+        
+        if (_meta.isMapped())
+            code.constant().setValue(_meta.getTypeAlias());
+        else
+            code.constant().setNull();
+
         if (_pc.isAbstract())
             code.constant().setNull();
         else {

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java?view=diff&rev=532805&r1=532804&r2=532805
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
Thu Apr 26 10:17:10 2007
@@ -1396,14 +1396,16 @@
 
         // set alias for class
         String alias = PCRegistry.getTypeAlias(cls);
-        synchronized (_aliases) {
-            List classList = (List) _aliases.get(alias);
-            if (classList == null) {
-                classList = new ArrayList(3);
-                _aliases.put(alias, classList);
+        if (alias != null) {
+            synchronized (_aliases) {
+                List classList = (List) _aliases.get(alias);
+                if (classList == null) {
+                    classList = new ArrayList(3);
+                    _aliases.put(alias, classList);
+                }
+                if (!classList.contains(cls))
+                    classList.add(cls);
             }
-            if (!classList.contains(cls))
-                classList.add(cls);
         }
     }
 

Added: incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/TestSharedUnqualifiedClassNames.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/TestSharedUnqualifiedClassNames.java?view=auto&rev=532805
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/TestSharedUnqualifiedClassNames.java
(added)
+++ incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/TestSharedUnqualifiedClassNames.java
Thu Apr 26 10:17:10 2007
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.inheritance;
+
+import org.apache.openjpa.persistence.test.SingleEMFTestCase;
+import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.apache.openjpa.meta.ClassMetaData;
+import org.apache.openjpa.kernel.AbstractBrokerFactory;
+
+/**
+ * Test that entities, mapped superclasses, and embeddables can all share
+ * the same short names without any collisions.
+ */
+public class TestSharedUnqualifiedClassNames
+    extends SingleEMFTestCase {
+
+    public void setUp() {
+        setUp(org.apache.openjpa.persistence.inheritance.mappedsuperclass
+                .SharedName1.class,
+            org.apache.openjpa.persistence.inheritance.entity
+                .SharedName1.class,
+            org.apache.openjpa.persistence.inheritance.embeddable
+                .SharedName2.class,
+            org.apache.openjpa.persistence.inheritance.entity
+                .SharedName2.class);
+        emf.createEntityManager().close();
+    }
+
+        public void testMappedSuperclass() {
+        ClassMetaData meta = emf.getConfiguration()
+            .getMetaDataRepositoryInstance()
+            .getMetaData("SharedName1", getClass().getClassLoader(), true);
+        assertEquals(
+            org.apache.openjpa.persistence.inheritance.entity.SharedName1.class,
+            meta.getDescribedType());
+    }
+
+    public void testEmbeddable() {
+        ClassMetaData meta = emf.getConfiguration()
+            .getMetaDataRepositoryInstance()
+            .getMetaData("SharedName2", getClass().getClassLoader(), true);
+        assertEquals(
+            org.apache.openjpa.persistence.inheritance.entity.SharedName2.class,
+            meta.getDescribedType());
+    }
+}



Mime
View raw message