New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cannot find by UUID field in PanacheMongoEntity #10941
Comments
/cc @FroMage, @loicmathieu |
@rmanibus How are your UUID fields rendered inside the MongoDB collection? Are they String ? Did you persist your entity via the same code ? Can you please try with the following code:
MongoDB with Panache uses the MongoDB typed mongo collection, and MongoDB provides a |
They are not stored as String, when I changed objectId type from UUID to String I got a incompatible type error because of the data that was previously stored, looking at the error message, It seems they where stored as binary. Yes I persisted the data with panache ( .persist() ) What do you mean by try the following code ? it's exactly what I tried already :) |
you mean doing a toString() on the UUID ? |
Yes I hit send too quickly ;)
Yes, I what the UuidCodec does and it do store them as binay. We will need to implements special treatment for UUID inside MongoDB with Panache to make this works. |
toString() is not working either (it is consistant with the fact that UUID are stored as binary) |
Looking at my data in mongo client I have: |
Well, it's better, with the PR the request sent to the db is:
so the UUID is correctly transformed to binary but I still get a 0 count Which is weird because the following query return values with mongo client:
|
That's because it is parsed as a legacy UUID.
Values fetched by findById() have the correct sub type
|
There is this weird function in org.bson.json.JsonReader:
which is passed the value "UUID" but the condition make it always return UUID_LEGACY Edit: it seems fixed on the In the 4.1.x branch of the driver (they removed the legacy). I created a PR to fix this in the 4.0.x branch: Should I upgrade the mongo client to 4.1.0-rc0 in this PR ? (I tried and it's working as expected, subtype is 04) |
When using the following PanacheMongoEntity:
The following request always return 0, even if some data is present:
My connection String is :
In an other entity, I use UUID as primary ID and I can find them with findById(UUID).
Replacing UUID by String make this working.
I'm using Quarkus 1.6.1
The text was updated successfully, but these errors were encountered: