Can I use updateChildren()
using a map of arbitrary (Firebase-friendly) objects in the same way I can use setValue()
? The following works fine:
public void addReview(FbReview review, AddCallback callback) {
Firebase root = mDataRoot.child(REVIEWS_ROOT).child(review.getReviewId());
root.setValue(review, newAddListener(review, callback));
}
where FbReview is a simple data holder class with an empty constructor and with getters for automatic data structuring (using objects in setValue()
is shown in the Firebase documentation for setValue()
However if I try the equivalent updateChildren()
follow-on example from the webpage:
@Override
public void addReview(FbReview review, AddCallback callback) {
Map<String, Object> updates = new HashMap<>();
updates.put(REVIEWS_ROOT + "/" + review.getReviewId(), review);
mDataRoot.updateChildren(updates, newAddListener(review, callback));
}
I get an error that suggests the FbReview object I've defined cannot be parsed:
FirebaseException: Failed to parse node with class ... FbReview
If I try the above updateChildren()
code but pass a String (review.getSubject()
say) rather than an object it works fine suggesting that object parsing doesn't work with updateChildren()
.
Is this correct?