What version are you using? (Morphia 0.99/Driver 2.7.2/MongoDB 2.0.2)
[SCOPE and ISSUE]
Using the following class hierarchy:
@Entity("mycollection")
public abstract class AbstractParent
{
...
}
public class Child extends AbstractParent
{
private String childField;
private String anotherChildField;
...
}
and constructing a query like this:
Query<AbstractParent> q = ...
q.field("childField").equals("test");
I'm ensuring that only Child instances will be retrieved from the collection.
Now, I want to retrieve only a subset of the fields of documents retrieved by
the query, so I simply construct the query like the following one:
Query<AbstractParent> q = ...
q.field("childField").equals("test");
q.retrievedFields(true, "anotherChildField");
I get a java.lang.InstantiationException.
The issue is related to the lack of "className" in the list of fields to
retrieve.
[WORKAROUND]
Query<AbstractParent> q = ...
q.field("childField").equals("test");
q.retrievedFields(true, "className", "anotherChildField");
I'm wondering if this "behaviour" should be addressed "by design"
enforcing "className" when a query is constructed using retrievedFields.
Thanks.
Luca
Original issue reported on code.google.com by nataluca@gmail.com on 8 Feb 2012 at 11:21
Original issue reported on code.google.com by
nataluca@gmail.com
on 8 Feb 2012 at 11:21