I have a class hierarchy designed for store user notifications:
@Document
public class Notification {
@Id
private String id;
@DBRef
priv
Since you look like you are only querying by _id
I believe you can do:
db.NotificationA.findOne({"tag.$id": ObjectId("blah")});
However:
But I need to query on the fields of JetAnotherClass (two levels of @DBRef fields).
DBRefs are not JOINs, they are merely a self describing _id
in the event that you do not know the linking collection it will create a helper object so you don't have to code this yourself on the client side.
You can find more on DBRefs here: http://docs.mongodb.org/manual/applications/database-references/
Basically you can query the sub fields within the DBRef from the same document, i.e.: DBRef.$_id
but you cannot, server-side, resolve that DBRef and query on the resulting fields.