[JAVA-2600] Pojo class can't implement Iterable Created: 15/Sep/17 Updated: 27/Oct/23 Resolved: 03/Oct/17 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Codecs |
| Affects Version/s: | 3.5.0 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Patrick Dekker | Assignee: | Unassigned |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Debian Linux & Windows |
||
| Description |
|
I was experimenting a bit with the POJO support added in 3.5. Just using the automatic PojoCodecProvider. But I noticed a weird behavior. When your POJO class implements Iterable. The BSON conversion generates an array type instead document type. I think this is a bug, You can reproduce it by using the PojoQuickTour example, Just make the Person implements Iterable<Address>, and implement the iterator<Address> and suddenly the code start failing/ |
| Comments |
| Comment by Ross Lawley [ 15/Sep/17 ] |
|
Hi dekker_p, This is expected behaviour an Iterable maps to a Bson Array and a Map<String, Object> maps to a Bson Document. As such you cannot have a top level POJO that represents an iterable. I hope that helps, Ross |