Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vals-productions opened this issue Aug 16, 2022 · 3 comments
Labels
status: feedback-provided Feedback has been provided

Comments

@vals-productions
Copy link

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 16, 2022
@mikereiche
Copy link
Collaborator

mikereiche commented Aug 16, 2022

Fixed in #868

Please use the latest version which is 4.4.2. https://spring.io/projects/spring-data-couchbase

Couchbase Transactions are integrated into Spring Data Couchbase beginning in 5.0.0-M5 (prerelease milestone 5)

The transactions documentation which will appear in the next release (5.0.0-M6 is currently staged at https://mikereiche.github.io/staged/ (look for the Transactions section).

There are all kinds of examples spring-data-couchbase/src/test/java in : git clone [email protected]:spring-projects/spring-data-couchbase.git. (search for test cases with 'Transaction' in the name).

@mikereiche mikereiche added status: feedback-provided Feedback has been provided and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 16, 2022
@vals-productions
Copy link
Author

I was using 4.4.0 that was supposed to have the fix. Upgraded to 4.4.2 but still get the issue. I also reproduced the issue
with List<Map<>> data structure mentioned as fixed in #868 .

I think that maybe the issue was re-introduced or not transferred into collections? As 4.0.2 is pre-collections release.

@mikereiche
Copy link
Collaborator

mikereiche commented Aug 17, 2022

Sorry - I didn't read far enough into your post.
Use entityDoc.export() instead of entityDoc.getContent(). See #1524

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: feedback-provided Feedback has been provided
Projects
None yet
Development

No branches or pull requests

3 participants