[JAVA-3597] add `MongoDatabase.withUuidRepresentation` so that it can be changed at runtime Created: 21/Jan/20  Updated: 21/Jan/20  Resolved: 21/Jan/20

Status: Closed
Project: Java Driver
Component/s: Codecs, Configuration
Affects Version/s: 4.0.0
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Justin Lee Assignee: Jeffrey Yemin
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Much like the `withCodecRegistry()` methods and the like, this would allow users (Morphia in my case) to ensure a properly configured environment. 



 Comments   
Comment by Jeffrey Yemin [ 21/Jan/20 ]

OK, thanks Justin. I'll close this out then.

Comment by Justin Lee [ 21/Jan/20 ]

At the moment, i have an option on `MapperOptions` to select that representation.  It currently defaults to `STANDARD`, iirc.  If a user doesn't pass in a `MongoClient`, I use that option to configure it.  An argument could be made that if folks are passing in their own client refs they should configure them correctly.  Alternately, Morphia could configure that for them if the option value is non-null.  (We'd have to change that default, obviously.)  This idea seemed more urgent in the dark of night with failing tests but having slept on it, I'm perfectly ok with just documenting the need to configure that if 1) they create their own client and 2) they even use UUIDs at all.  Most users probably won't.

Comment by Jeffrey Yemin [ 21/Jan/20 ]

jlee@antwerkz.com can you give a sense of how Morphia would use this? Given that Morphia users are just as likely as anyone else to have legacy UUID byte orders stored in MongoDB, I don't think Morphia, or any library, should unilaterally declare the UUID representation for the application.

Generated at Thu Feb 08 08:59:59 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.