[JAVA-2972] serialization by field Convention Created: 11/Sep/18 Updated: 08/Jan/19 Resolved: 08/Jan/19 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | POJO |
| Affects Version/s: | 3.8.1 |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Vitali Pankraz | Assignee: | Ross Lawley |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
JDK 8, Windows 10 |
||
| Issue Links: |
|
||||||||
| Description |
|
When serializing a POJO the properties are identified by** getter methods, *setter methods and* fields. (see http://mongodb.github.io/mongo-java-driver/3.6/bson/pojos/) If the POJO impl. contains non standard getter e.g.
a property "calculation" with some value will be serialized which is not intendet. Sure, you can use some @BsonIgnore annotation to avoid that but you have to check the serialization bahaviour every time the POJO is extended by some get*() method. Another issue is when integrating a given POJO with large amount of such non-standard get*() methods. It would be a great benefit to register some Convention which says: "serialize only the fields and ignore getter methods".
|
| Comments |
| Comment by Ross Lawley [ 08/Jan/19 ] |
|
Please watch JAVA-3097 for updates on this feature. |
| Comment by Ross Lawley [ 08/Jan/19 ] |
|
Thanks for the ticket, a similar request came out of another ticket and resulted in JAVA-3097. I think if the driver provides a flexible convention that allows explicit definitions of what should be included then it will achieve your goals as well. Ross |