[JAVA-2373] org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class org.joda.time.DateTime. Created: 27/Oct/16 Updated: 11/Sep/19 Resolved: 27/Nov/16 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Codecs |
| Affects Version/s: | 3.3.0 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Avinash Venkatesaiah | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
I use the aggregate functionality of the DBcollection. However the aggregate functionality internally uses the default mongo codecs and is not picking up the codec that i have registered with the mongo client as part of the mongoClientOptions. Ideally it should consider the codec registry registered by the user and not the default ? |
| Comments |
| Comment by Jeffrey Yemin [ 27/Nov/16 ] |
|
See this section of the reference documentation. |
| Comment by Avinash Venkatesaiah [ 27/Oct/16 ] |
|
Can you help me with an example to get the handle to a collection of type MongoCollection ? Or how to register the encoder and decoder? |
| Comment by Jeffrey Yemin [ 27/Oct/16 ] |
|
The documentation for MongoClientOptions#getCodecRegistry states that
In order to make use of the registry you will need to use the new MongoCollection class. If you have to stick with DBCollection, you might try BSON#addDecodingHook and BSON#addEncodingHook instead. |