Here's my entity's definition:
@Entity("Comment")
public class Comment extends BaseEntity {
@Reference
private Merchant merchant;
...
}
@Entity("Merchant")
class Merchant extends BaseEntity{
@Id
@Property("id")
protected ObjectId id;
...
}
And here's my data:
comment:{
"_id": ObjectId("546c1ac64652e5180dc21577"),
"merchant" : DBRef("Merchant", ObjectId("546c1ac64652e5180dc21576")),
...
}
When I create a Query like:
Query<Comment> query = ds.createQuery(Comment.class);
query.field("merchant").equal(new ObjectId("546c1ac64652e5180dc21576"));
commentDao.findOne(query);
There's no result returned, I'd like to ask which is the right way to query a comment data with merchant's ObjectId?
Thanks for your help.
I think you need to disable validation, otherwise you'll see some rather unnecessary warning.
You can query the DBRef ID directly, but since DBRef itself is typed, I'd not circumvent it unless you have some valid reason.