[JAVA-2513] org.bson.codecs.configuration.CodecConfigurationException in when update document with specified array field Created: 08/May/17 Updated: 27/Oct/23 Resolved: 22/Jun/17 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | BSON |
| Affects Version/s: | 3.4.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Ehsan Farahani Asil | Assignee: | Ross Lawley |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
i want to update userinfo.languages filled in this document. , { "name": "Persian", "level": "Native" } ], i use this code for update public class UserInfo { public void setLanguages(List<Language> languages) { this.languages = languages; }} public class Language { public String getName() { return name; }public void setName(String name) { this.name = name; }public String getLevel() { return level; }public void setLevel(String level) { this.level = level; }} i problem with update each field that like languages use list<> or arrayList. in other filed that use integer, Boolean, string, double i don't have any problems. Best Regards |
| Comments |
| Comment by Ehsan Farahani Asil [ 09/May/17 ] |
|
thanks very much. i solve this problem with this action. first get document and then updated specified changed field. Best Regards |
| Comment by Ross Lawley [ 08/May/17 ] |
|
Hi ehsansis0, The error is because the Mongo Java Driver doesn't have a Codec for the Language object and therefore doesn't know how to convert it into BSON. The next release (3.5) will provide a POJO Codec which will allow you to easily register POJO's instances into the Codec Registry. Until then you either must handwrite a Codec or convert to a Document manually and then update with that object. I hope that helps, Ross |