Proposal: support Kotlin value classes (and other form of wrapped IDs) #2396
Replies: 2 comments
-
|
I can provide a PR. |
Beta Was this translation helpful? Give feedback.
-
|
I don't yet fully understand in that the expected approach is to have an AttributeConverter
If there was defined and registered (querybean-generator / kotlin-querybean-generator should automatically detect AttributeConverter's and include them in the generated code so that they are registered with ebean (without classpath scanning or need for developers to write code to register them). So the expectation is to write an AttributeConverter and annotate it with |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Kotlin value classes are perfect typed wrappers for typical singular entity IDs:
Currently, enhancers see it as a wrapped type (UUID in the example) and persist works perfectly.
Problems arise when we try to query such entities:
findnotQueycan't convert values passed as is and see value class itself (OrderId)IdBinder.convertId- it is always delegated toScalarType. ButScalarTypefor such properties is a wrapped type (UUID).Simple reflection based value class unwrap function:
Current code thows:
Suggested solution:
Beta Was this translation helpful? Give feedback.
All reactions