Modified:
/trunk/morphia/src/main/java/com/google/code/morphia/query/Query.java
/trunk/morphia/src/main/java/com/google/code/morphia/query/QueryImpl.java
=======================================
--- /trunk/morphia/src/main/java/com/google/code/morphia/query/Query.java
Sun Nov 6 16:53:00 2011
+++ /trunk/morphia/src/main/java/com/google/code/morphia/query/Query.java
Wed Feb 22 23:01:00 2012
@@ -96,6 +96,9 @@
/** Limits the fields retrieved */
Query<T> retrievedFields(boolean include, String...fields);
+ /** Limits the fields retrieved to those of the query type -- dangerous
with interfaces and abstract classes*/
+ Query<T> retrieveKnownFields();
+
/** Enabled snapshotted mode where duplicate results
* (which may be updated during the lifetime of the cursor)
* will not be returned. Not compatible with order/sort and hint. **/
=======================================
---
/trunk/morphia/src/main/java/com/google/code/morphia/query/QueryImpl.java
Wed Feb 22 22:07:40 2012
+++
/trunk/morphia/src/main/java/com/google/code/morphia/query/QueryImpl.java
Wed Feb 22 23:01:00 2012
@@ -17,6 +17,7 @@
import com.google.code.morphia.logging.Logr;
import com.google.code.morphia.logging.MorphiaLoggerFactory;
import com.google.code.morphia.mapping.MappedClass;
+import com.google.code.morphia.mapping.MappedField;
import com.google.code.morphia.mapping.Mapper;
import com.google.code.morphia.mapping.cache.EntityCache;
import com.mongodb.BasicDBObject;
@@ -502,6 +503,16 @@
this.fields = fields;
return this;
}
+
+ public Query<T> retrieveKnownFields(){
+ MappedClass mc = this.ds.getMapper().getMappedClass(clazz);
+ ArrayList<String> fields = new
ArrayList<String>(mc.getPersistenceFields().size()+1);
+ for(MappedField mf : mc.getPersistenceFields()) {
+ fields.add(mf.getNameToStore());
+ }
+ retrievedFields(true, (String[]) fields.toArray());
+ return this;
+ }
/** Enabled snapshotted mode where duplicate results
* (which may be updated during the lifetime of the cursor)