[JAVA-2943] Unable to list all the documents in my collection. Created: 23/Aug/18 Updated: 11/Sep/19 Resolved: 12/Sep/18 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | API |
| Affects Version/s: | 3.8.1 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Critical - P2 |
| Reporter: | Durga Deep | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
mac |
||
| Description |
|
I have a very simple POJO - where I don't have an _id field ( I let mongo generate the _id field for me ). I am able to insert / update and delete successfully. But when i try to list out all the POJO instances in my collection
I get the following error - We are using mongodb-driver-reactivestreams (1.9.0) {{}}
|
| Comments |
| Comment by Ross Lawley [ 12/Sep/18 ] | ||||
|
Hi durgadeep, I've closed this ticket as I think we identified the cause and workaround for your issue. Just to let you know for future reference this project is for Java driver bugs or feature requests. The best place for questions regarding MongoDB usage or the Java driver specifics is the mongodb-user mailinglist or stackoverflow as you will reach a boarder audience there. If your business requires an answer from MongoDB within a time frame then we do offer production support. If you do follow up via one of the options above please post a link and I will follow the conversation there. All the best, Ross | ||||
| Comment by Ross Lawley [ 03/Sep/18 ] | ||||
|
Hi durgadeep, This should automatically be handled by the CLASS_AND_PROPERTY_CONVENTION. If you are using the default conventions then it is likely that the document was added to the collection without a set id property and an ObjectId was created. Could this be the case? As mentioned previously, you may need a custom codec to handle the converstion of ObjectId's to Strings - or just use ObjectIds if you don't require a String primary key. Kind Regards, Ross | ||||
| Comment by Durga Deep [ 30/Aug/18 ] | ||||
|
You're spot on - here is my POJO
When I persist - I am setting the id - but this is not the _id that is auto generated. How do I solve this ?.
Thanks Much _Durga Deep | ||||
| Comment by Ross Lawley [ 29/Aug/18 ] | ||||
|
Hi durgadeep, Can you please supply the FooBar POJO? From the error it looks like you have an id property that is a String but when decoding the PojoCodec found a ObjectID value and has errored. If you may need a custom codec to handle the converstion of ObjectId's to Strings - or just use ObjectIds if you don't require a String primary key. Ross |