Skip to content

MappingCouchbaseConverter.write() does not provide equivalent target for lists #1540

Closed
@vals-productions

Description

@vals-productions

Simplified document:

@Document
public class Entity  {
...
	private List<EmailToken> tokenList = new LinkedList<>();

	public static class EmailToken {
		private String token;
		private String type; 
...

Saved through Repository the JSON looks like the following:

{
 ...
  "tokenList": [
    {
      "token": "G1LTUPAPVQ1JGGE",
      "type": "Type 1"
    }
  ]
... 
}

I wanted to try transaction stuff and tried to save the same object through the code suggested in docs:
Transaction Support

CouchbaseDocument entityDoc = new CouchbaseDocument(entity.getId());
mappingCouchbaseConverter.write(entity, entityDoc);
ctx.insert(
	couchbaseClientFactory.withScope("some scope").getCollection("someColl"), 
	entityDoc.getId()(), 
	entityDoc.getContent());

The result looks like the following:

{
...
  "tokenList": {
    "empty": false
  }
...
}

tokenList becomes a Map instead of a List with data loss.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions