openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r785341 [3/3] - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/ openjpa-persistence/src/main/java/org/apache/openjpa/persiste...
Date Tue, 16 Jun 2009 18:56:58 GMT
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=785341&r1=785340&r2=785341&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
Tue Jun 16 18:56:57 2009
@@ -119,6 +119,10 @@
         public boolean isOptional() {
             return fmd.getNullValue() != FieldMetaData.NULL_EXCEPTION;
         }
+        
+        public boolean isEmbedded() {
+            return fmd.isEmbedded();
+        }
 
         public Type<T> getAttributeType() {
             return owner.model.type(fmd.getDeclaredType());

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/MetamodelImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/MetamodelImpl.java?rev=785341&r1=785340&r2=785341&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/MetamodelImpl.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/MetamodelImpl.java
Tue Jun 16 18:56:57 2009
@@ -45,6 +45,11 @@
 import javax.persistence.metamodel.AbstractCollection.CollectionType;
 import javax.persistence.metamodel.Type.PersistenceType;
 
+import org.apache.openjpa.conf.OpenJPAConfiguration;
+import org.apache.openjpa.kernel.QueryContext;
+import org.apache.openjpa.kernel.exps.AggregateListener;
+import org.apache.openjpa.kernel.exps.FilterListener;
+import org.apache.openjpa.kernel.exps.Resolver;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.meta.ClassMetaData;
 import org.apache.openjpa.meta.FieldMetaData;
@@ -57,7 +62,7 @@
  * @author Pinaki Poddar
  * 
  */
-public class MetamodelImpl implements Metamodel {
+public class MetamodelImpl implements Metamodel, Resolver {
     public final MetaDataRepository repos;
     private Map<Class<?>, Entity<?>> _entities = 
         new HashMap<Class<?>, Entity<?>>();
@@ -79,6 +84,8 @@
             switch (type) {
             case ENTITY:
                 find(cls, _entities, ENTITY);
+                if (meta.isEmbeddable())
+                    find(cls, _embeddables, EMBEDDABLE);
                 break;
             case EMBEDDABLE:
                 find(cls, _embeddables, EMBEDDABLE);
@@ -115,6 +122,10 @@
         return result;
     }
 
+    public ClassMetaData getMetaData(Types.Identifiable<?> managedType) {
+        return managedType.meta;
+    }
+    
     public <X> ManagedType<X> type(Class<X> clazz) {
         if (_entities.containsKey(clazz))
             return (Entity<X>) _entities.get(clazz);
@@ -163,16 +174,19 @@
         Map<Class<?>,V> container, PersistenceType expected) {
         ClassMetaData meta = repos.getMetaData(cls, null, true);
         PersistenceType actual = getPersistenceType(meta);
-        if (actual != expected)
-            throw new IllegalArgumentException(_loc.get("type-wrong-category",
-                cls, actual, expected).getMessage());
-
+        if (actual != expected) {
+            if (!meta.isEmbeddable() || actual != PersistenceType.ENTITY ||
+                expected != PersistenceType.EMBEDDABLE) 
+                throw new IllegalArgumentException(
+                    _loc.get("type-wrong-category",
+                    cls, actual, expected).getMessage());
+        }
         switch (actual) {
         case EMBEDDABLE:
             Types.Embeddable<X> embedded = new Types.Embeddable<X>(meta, this);
             _embeddables.put(cls, embedded);
             populate(embedded);
-            break;
+//            break;
         case ENTITY:
         	Types.Entity<X> entity = new Types.Entity<X>(meta, this);
             _entities.put(cls, entity);
@@ -325,5 +339,25 @@
         java.lang.reflect.Type elementType = args[1];
         if (fType.isPrimitive())
             return;
+    }
+
+    public Class classForName(String name, String[] imports) {
+        throw new UnsupportedOperationException();
+    }
+
+    public AggregateListener getAggregateListener(String tag) {
+        throw new UnsupportedOperationException();
+    }
+
+    public OpenJPAConfiguration getConfiguration() {
+        return repos.getConfiguration();
+    }
+
+    public FilterListener getFilterListener(String tag) {
+        throw new UnsupportedOperationException();
+    }
+
+    public QueryContext getQueryContext() {
+        throw new UnsupportedOperationException();
     }    
 }

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/Types.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/Types.java?rev=785341&r1=785340&r2=785341&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/Types.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/Types.java
Tue Jun 16 18:56:57 2009
@@ -76,7 +76,7 @@
         }
 
         public String toString() {
-            return "" + cls;
+            return cls.getName();
         }
     }
 
@@ -191,9 +191,7 @@
                      .getMessage());
                 }
                 // TODO: Account for the following codes
-                // case ARRAY = 11;
                 // case PC_UNTYPED = 27;
-                // case OID = 29;
                 // case INPUT_STREAM = 30;
                 // case INPUT_READER = 31;
             }



Mime
View raw message