gora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lewi...@apache.org
Subject [36/50] [abbrv] git commit: Skip fields which are not mapped (for instance _g_dirty)
Date Wed, 04 Jun 2014 16:36:53 GMT
Skip fields which are not mapped (for instance _g_dirty)


Project: http://git-wip-us.apache.org/repos/asf/gora/repo
Commit: http://git-wip-us.apache.org/repos/asf/gora/commit/7b6ce7f2
Tree: http://git-wip-us.apache.org/repos/asf/gora/tree/7b6ce7f2
Diff: http://git-wip-us.apache.org/repos/asf/gora/diff/7b6ce7f2

Branch: refs/heads/master
Commit: 7b6ce7f2dca01dba249ed5d6a0f2eb6589d7cb10
Parents: 56cc8cd
Author: Damien Raude-Morvan <damien@dictanova.com>
Authored: Thu May 22 15:43:07 2014 +0200
Committer: Damien Raude-Morvan <damien@dictanova.com>
Committed: Thu May 22 15:45:00 2014 +0200

----------------------------------------------------------------------
 .../org/apache/gora/mongodb/store/MongoStore.java     | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/gora/blob/7b6ce7f2/gora-mongodb/src/main/java/org/apache/gora/mongodb/store/MongoStore.java
----------------------------------------------------------------------
diff --git a/gora-mongodb/src/main/java/org/apache/gora/mongodb/store/MongoStore.java b/gora-mongodb/src/main/java/org/apache/gora/mongodb/store/MongoStore.java
index c839ad5..6ff3b2c 100644
--- a/gora-mongodb/src/main/java/org/apache/gora/mongodb/store/MongoStore.java
+++ b/gora-mongodb/src/main/java/org/apache/gora/mongodb/store/MongoStore.java
@@ -345,8 +345,12 @@ public class MongoStore<K, T extends PersistentBase> extends
     // Prepare the MongoDB query
     BasicDBObject q = new BasicDBObject("_id", key);
     BasicDBObject proj = new BasicDBObject();
-    for (String field : fields)
-      proj.put(mapping.getDocumentField(field), true);
+    for (String field : fields) {
+      final String docf = mapping.getDocumentField(field);
+      if (docf != null) {
+        proj.put(docf, true);
+      }
+    }
     // Execute the query
     DBObject res = mongoClientColl.findOne(q, proj);
     // Build the corresponding persistent and clears its states
@@ -528,11 +532,7 @@ public class MongoStore<K, T extends PersistentBase> extends
     for (String f : fields) {
       // Check the field exists in the mapping and in the db
       String docf = mapping.getDocumentField(f);
-      if (docf == null) {
-        throw new RuntimeException("Mongo mapping for field [" + f
-            + "] not found. " + "Wrong gora-mongo-mapping.xml?");
-      }
-      if (!easybson.containsField(docf))
+      if (docf == null || !easybson.containsField(docf))
         continue;
 
       DocumentFieldType storeType = mapping.getDocumentFieldType(docf);


Mime
View raw message