javamongodbjongomongojack

MongoDriver UUID Support


Im having some issues with mongo driver and the way its inserting UUIDs by default in Java. (Mongo driver version 3.2)

UUID("...") => BinData(4, "...")

LUUID("...") => BinData(3, "...") legacy UUID in unspecified encoding

My UUIDs are being inserted in the legacy format, and I cant seem to find a way to insert them using the V4 binary. Do you know of a way to handle insert using V4 in mongo driver. Or if any alternate libraries such as MongoJack or JongoMongo support this insert?

Edit: It would seem MongoJack and Jongo aren't supporting Mongo V3 fully yet. Are there any potential work arounds for this that don't involve the use of custom Codecs?


Solution

  • Currently neither of these options support UUID binary type 4, our solution was to use the mongo driver v3.x and parse .withCodecRegistries on the collection itself. We could then specify how we handled our UUIDs.