morphia icon indicating copy to clipboard operation
morphia copied to clipboard

upsert of $inc with map of map throwing ValidationException

Open ball3t opened this issue 1 year ago • 1 comments

I have an document like this:

{
    "resultCounts": {
        "abc": {
            "count1": 10,
            "count2": 0
        },
        "def": {
            "count1": 0,
            "count2": 20
        }
    }
}

and the java codes are like:

public class SomeLog {
  private Map<String, Map<String,Integer>> resultCounts;
  ...
}

when I try to do an upsert using this:

updates.add(inc("resultCounts.abc.count1", 1));
getDatastore().find(SomeLog .class).filter(eq("id", id)).update(updates).execute(new UpdateOptions().upsert(true));

it throws exception:

Failed to process request to: [{"expectMultipart":false,"paramsCharset":"UTF-8","ended":false,"ssl":false}]: dev.morphia.query.ValidationException: Could not resolve path 'resultCounts.abc.count1' against 'com.kn.fitnext.common.entity.DcLog'.  Unknown path element: 'count1'.

** Please complete the following information: ** Server Version: 6.0.12 Driver Version: 4.9.1 Morphia Version: 2.2.10

ball3t avatar Jun 04 '24 11:06 ball3t