AnsweredAssumed Answered

MapR DB OJAI - custom class support differentiation in insert and mutate operations

Question asked by ondrad on Nov 7, 2017
Latest reply on Nov 13, 2017 by cathy


I'm facing strange errors with updating JSON document in MapR DB (5.2.2). My classes look like:

class A {
private String X;
private String Y;
private List<B> bees;
class B {
private String foo;
private String bar;


Following code works as expected:

Document document = MapRDB.newDocument(A);

But if I want to replace property bees in class/document A with:

List<B> list = new ArrayList<B>();
list.add(new B());
DocumentMutation dm = MapRDB.newMutation().setOrReplace("bees", list);
Table.update(a._id, dm);

it crashes with:

org.ojai.exceptions.TypeException: Unsupported object type of class: class my.domain.B
    at com.mapr.db.rowcol.DBValueBuilderBase.initFromObjectType( ~[maprdb-]
    at com.mapr.db.rowcol.DBValueBuilderImpl.initFromObject( ~[maprdb-]
    at com.mapr.db.rowcol.DBValueBuilderImpl.initFrom( ~[maprdb-]
    at com.mapr.db.rowcol.MutationImpl.setOrReplace( ~[maprdb-]
    at com.mapr.db.rowcol.MutationImpl.setOrReplace( ~[maprdb-]

Following scenario works only if class B is primitive or String. Based on documentation all classes should supported:

DocumentMutation setOrReplace(FieldPath path, List<? extends Object> list)
Sets or replaces the field at the given FieldPath to the specified List.
path - path of the field that needs to be updated
list - The new value to set at the FieldPath

Is this some undocumented limitation or is it bug?



temporary workaround is to create List with ojai Document class, but this is at least ugly (e.g. all lists with custom classes needs to be manually converted)