openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fayw...@apache.org
Subject svn commit: r930721 - in /openjpa/trunk: openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestMetamodel.java openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/Members.java
Date Sun, 04 Apr 2010 17:28:53 GMT
Author: faywang
Date: Sun Apr  4 17:28:52 2010
New Revision: 930721

URL: http://svn.apache.org/viewvc?rev=930721&view=rev
Log:
OPENJPA-1611: fix EMBEDDED attr type

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestMetamodel.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/Members.java

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestMetamodel.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestMetamodel.java?rev=930721&r1=930720&r2=930721&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestMetamodel.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestMetamodel.java
Sun Apr  4 17:28:52 2010
@@ -38,6 +38,8 @@ import javax.persistence.metamodel.Plura
 import javax.persistence.metamodel.Type.PersistenceType;
 
 import org.apache.openjpa.meta.ClassMetaData;
+import org.apache.openjpa.persistence.embed.Address;
+import org.apache.openjpa.persistence.embed.Geocode;
 import org.apache.openjpa.persistence.enhance.identity.Book;
 import org.apache.openjpa.persistence.enhance.identity.BookId;
 import org.apache.openjpa.persistence.enhance.identity.Library;
@@ -71,7 +73,9 @@ public class TestMetamodel extends Singl
     	        OneOneChild.class,
     	        Book.class,
     	        Library.class,
-    	        Page.class);
+    	        Page.class,
+    	        Address.class,
+    	        Geocode.class);
     	emf.createEntityManager();
         model = (MetamodelImpl)emf.getMetamodel();
         }
@@ -313,6 +317,12 @@ public class TestMetamodel extends Singl
         assertEquals(PersistentAttributeType.BASIC, pInt.getPersistentAttributeType());
     }
     
+    public void testEmbeddedAttributeType() {
+        ManagedType<Address> type = model.entity(Address.class);
+        Attribute.PersistentAttributeType attr = type.getAttribute("geocode").getPersistentAttributeType();
+        assertEquals(PersistentAttributeType.EMBEDDED, attr);
+    }
+    
     public void testNotFoundErrorMessage() {
         IdentifiableType<ImplicitFieldAccessBase> e0 = model.entity(ImplicitFieldAccessBase.class);
         String name = "unknown";

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/Members.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/Members.java?rev=930721&r1=930720&r2=930721&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/Members.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/Members.java
Sun Apr  4 17:28:52 2010
@@ -200,6 +200,10 @@ public class Members {
         public final PersistentAttributeType getPersistentAttributeType() {
             if (!fmd.isDeclaredTypePC())
                 return super.getPersistentAttributeType();
+            if (fmd.getValue().isEmbedded() && fmd.getAssociationType() == 0) {
+                return PersistentAttributeType.EMBEDDED;
+            }
+            
             return fmd.getMappedByMetaData() == null || !fmd.getType().isAssignableFrom(Collection.class)
                  ? PersistentAttributeType.ONE_TO_ONE
                  : PersistentAttributeType.ONE_TO_MANY;



Mime
View raw message