-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Allow entities in quarkus-mongodb-panache-kotlin to use data class with val #45500
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
Comments
/cc @FroMage (panache), @geoand (kotlin), @loicmathieu (mongodb,panache) |
Thanks a lot for reporting this! I'll say right off the bat that I find it unlikely that Quarkus can do much here, however it's very hard to tell because the example application does not merely use Quarkus and Mongo, but it also seems to have some kind of DTO mapping layer. Have you tried checking a simplified version where Mongo Panache is used directly? |
@geoand I have added a new commit in the repository to remove shapeShift mapping. As you will see, tests are still failing if I use the Entity directly without any additional mapping step. |
This seems to be a limitation in the Mongo driver. There does seem to be a Kotlin driver as well, but I haven't tried |
@geoand not sure I understand your answer. I am using My point is : if this is not possible to use val, then the documentation page should be explicit about this limitation. In the current page, we have this |
Right, my point is that it's probably possible to improve on this, but it's not something Quarkus does anything about (it's the Mongo driver that handles it) at this point. |
I think the documentation means: |
…ugin quarkusio#45500 (cherry picked from commit 82f0e9b)
…ugin quarkusio#45500 (cherry picked from commit 82f0e9b)
Description
I have a project using mongodb-panache-kotlin extension to manipulate data in a MongoDB. We follow the repository pattern as presented in the documentation, using Kotlin data classes.
The documentation found here states that the Kotlin data classes representing Mongo Entities can use either
val
orvar
for the properties.But I noticed that when using
val
, the Mongo driver returns an object withnull
values for every properties.I have a project to reproduce the issue here : https://github.com/loriepisicchio/mongo-panache-kotlin
You can run
UserMedicalStudyPanacheRepositoryTest
as integration test. You will see the tests failing because the object properties arenull
.If you change
val
s intovar
inUserMedicalStudyEntity
, the tests will pass.Let me know if you need more information.
Implementation ideas
No response
The text was updated successfully, but these errors were encountered: