openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fayw...@apache.org
Subject svn commit: r922688 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/
Date Sat, 13 Mar 2010 23:14:35 GMT
Author: faywang
Date: Sat Mar 13 23:14:35 2010
New Revision: 922688

URL: http://svn.apache.org/viewvc?rev=922688&view=rev
Log:
OPENJPA-1570: fix @Strategy inside MappedSuper class

Added:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/NonstandardMappingEntity4.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/NonstandardMappingMappedSuper4.java
Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/RuntimeStrategyInstaller.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestNonstandardMappingAnnotations.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/RuntimeStrategyInstaller.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/RuntimeStrategyInstaller.java?rev=922688&r1=922687&r2=922688&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/RuntimeStrategyInstaller.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/RuntimeStrategyInstaller.java
Sat Mar 13 23:14:35 2010
@@ -59,7 +59,7 @@ public class RuntimeStrategyInstaller
     public void installStrategy(FieldMapping field) {
         FieldStrategy strategy = null;
         ClassMapping owner = getOutermostDefiningMapping(field); 
-        if (owner != null && !owner.isEmbeddable())
+        if (owner != null && !owner.isEmbeddable() && !owner.isAbstract())
             strategy = repos.namedStrategy(field, true);
         if (strategy == null) {
             try {

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/NonstandardMappingEntity4.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/NonstandardMappingEntity4.java?rev=922688&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/NonstandardMappingEntity4.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/NonstandardMappingEntity4.java
Sat Mar 13 23:14:35 2010
@@ -0,0 +1,51 @@
+/*
+ * 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.jdbc.annotations;
+
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+
+
+@Entity
+@Table(name = "NONSTD_ENTITY4")
+public class NonstandardMappingEntity4 extends NonstandardMappingMappedSuper4 {
+    @Id
+    private long id;
+    
+    private String name;
+    
+    public long getId() { 
+        return id; 
+    }
+    
+    public void setId(long id) { 
+        this.id = id; 
+    }
+    
+    public String getName() {
+        return name;
+    }
+   
+    public void setName(String name) {
+        this.name = name;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/NonstandardMappingMappedSuper4.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/NonstandardMappingMappedSuper4.java?rev=922688&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/NonstandardMappingMappedSuper4.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/NonstandardMappingMappedSuper4.java
Sat Mar 13 23:14:35 2010
@@ -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.persistence.jdbc.annotations;
+
+
+import java.awt.Point;
+import java.util.*;
+
+import javax.persistence.*;
+
+import org.apache.openjpa.persistence.*;
+import org.apache.openjpa.persistence.jdbc.*;
+
+@MappedSuperclass
+public abstract class NonstandardMappingMappedSuper4 {
+
+    @Persistent
+    @Strategy("PointHandler")
+    @Column(name="my_point")
+    private Point point;
+    
+    public Point getPoint() { 
+        return point; 
+    }
+    
+    public void setPoint(Point point) { 
+        this.point = point; 
+    }
+   
+}

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestNonstandardMappingAnnotations.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestNonstandardMappingAnnotations.java?rev=922688&r1=922687&r2=922688&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestNonstandardMappingAnnotations.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/annotations/TestNonstandardMappingAnnotations.java
Sat Mar 13 23:14:35 2010
@@ -47,7 +47,7 @@ public class TestNonstandardMappingAnnot
     public void setUp() {
         setUp(NonstandardMappingEntity.class, NonstandardMappingEntity3.class, ExtensionsEntity.class,
             NonstandardMappingMappedSuper.class, EmbedValue2.class, EmbedValue3.class,
-            EmbedValue.class,
+            EmbedValue.class, NonstandardMappingEntity4.class, NonstandardMappingMappedSuper4.class,

             CLEAR_TABLES, RETAIN_DATA);
 
         // trigger complete resolution of metadata etc.
@@ -307,4 +307,25 @@ public class TestNonstandardMappingAnnot
         em.close();
     }
 
-}
+    public void testInsertAndRetrieveMappedSuperWithStrategy() {
+        NonstandardMappingEntity4 pc = new NonstandardMappingEntity4();
+        Point point = new Point();
+        point.setLocation(1, 2);
+        pc.setPoint(point);
+        pc.setId(1);
+        pc.setName("name1");
+        
+        OpenJPAEntityManager em = emf.createEntityManager();
+        em.getTransaction().begin();
+        em.persist(pc);
+        em.getTransaction().commit();
+        Object pcId = em.getObjectId(pc);
+        em.close();
+
+        em = emf.createEntityManager();
+        pc = em.find(NonstandardMappingEntity4.class, pcId);
+        assertEquals("name1", pc.getName());
+        assertEquals(1.0, pc.getPoint().getX());
+        assertEquals(2.0, pc.getPoint().getY());
+        em.close();
+    }}



Mime
View raw message