Spring Data Couchbase 4.0.0 – 保存带有列表的对象始终为空。

huangapple go评论76阅读模式
英文:

Spring data couchbase 4.0.0 - Save Object with list is always empty

问题

我目前正在将我的项目升级到 Spring Data Couchbase 4.0.0,但是在我想保存带有列表的对象时遇到了问题。我不确定我的代码中是否有错误,或者这是否是一个 bug,但我找不到任何关于这个问题的信息。

我有一个简单的用户对象,带有一个属性 role,它是一个 ArrayList。用户被添加了一个角色,然后调用了保存方法。userService 接口的 Repository 继承了 PagingAndSortingRepository,之前在 4.0.0 版本之前的版本中,正常的保存方法都能够正常工作。

user.getRole().add("ROLE_USER");
user.getRole().forEach(System.out::println);
// 将用户保存到数据库
this.userService.save(user);

对象 user 被正确保存,所有属性都被保存,除了列表。注释列表是空的,true 是正确的,角色为空,但没有数据。

"comment": {
  "empty": true
},
"role": {
  "empty": false
}

新版本中是否有什么变化,还是我做错了什么?

英文:

I am currently upgrading my project to spring data couchbase 4.0.0 and I am now experiencing problems when I want to save a Object with a list. I am not sure if there is an error in my code or this is a bug, but I could not find any informationen about this.

I have a simple user object with an attribute role, which is an ArrayList<String>. The user gets an role added and the save method is called. The interface userService Repository extends PagingAndSortingRepository and the normal save method is called, which worked before 4.0.0 perfectly.

user.getRole().add(&quot;ROLE_USER&quot;);
user.getRole().forEach(System.out::println);
//Save User in DB
this.userService.save(user);

The Object user is saved correctly, all attributes are saved except the List. The comment list was empty and the true is also correct, role is empty false but without data.

  &quot;comment&quot;: {
    &quot;empty&quot;: true
  },
  &quot;role&quot;: {
    &quot;empty&quot;: false
  },

Did something change with the new version or I am doing something wrong?

答案1

得分: 3

新版本的 Spring Data Couchbase 4.0.0 存在与保存列表/映射相关的错误。

根据文档,Spring Data Couchbase 应支持保存带有列表和组合对象的文档,但实际上并不支持。

完整的错误报告可以在这里找到:
Spring Jira Bugs - 关于列表和组合对象序列化的文档保存问题

英文:

There is a bug with the new version of spring data couchbase 4.0.0 with saving of list/maps.

> According to documentation spring data couchbase should support saving document with lists and composed objects, but it doesn't.

The full bug report can be found here:
Spring Jira Bugs - Document with list and composed object serialization works improperly

huangapple
  • 本文由 发表于 2020年5月29日 22:53:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/62088752.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定