-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Generate Kotlin data classes #6345
Comments
I agree that would be very desirable. May I ask you for some more details about the conflicts you've got? Perhaps, there's some easy solution to the problems you were having... |
The jooq interfaces declare get/set methods and for some reason the kotlin
compiler does not allow a kotlin property to "implement" this. Just give it
a try, if you have getUser/setUser and try to declare a kotlin property
var user and try to add the interface to the class, the kotlin errors go
wild.
https://youtrack.jetbrains.com/issue/KT-6653
|
@eiswind Oh interesting, thanks for elaborating. Yes, I've added my 2¢ to that Kotlin issue. A workaround for the time being would be to generate data classes that do not implement the generated interfaces, or generate Kotlin data classes that contain delegate getters and setters... Unfortunately, I don't think we can make a thorough fix in jOOQ 3.10 anymore. We'll definitely look into Kotlin code generation improvements in jOOQ 3.11, though. |
@eiswind Hey Thomas! Were you able to move this forward a bit? In general, how are you doing Kotlin code generation? I want to give it a shot. |
Currently we have a few big issues that hold us back from using jooq:
Is there any chance to get these features implemented one day? I would love to get rid of hibernate. Thanks a lot. Jooq is great and might become awesome ;) |
Thanks for your feedback, @bastman. Let me show you how none of these issues will hold you back:
Create your own for the time being! It's really simple, just extend the That said, let me increase the priority of this particular feature request (out of the box kotlin data class generation)
While I appreciate that people used to the convenience of Kotlin (or Scala, Ceylon, etc.) nullability guarantees would like to see this functionality also in Java, it is unreasonable to expect this from a SQL API. This is explained here: Anyway, this discussion has been had before many times, e.g. #4748 and #6244. JSR-305 is currently not an option for jOOQ's core, and if you like to have those annotations on your kotlin data classes, then see my previous answer, it'll be easy to generate them yourself.
Easy. Just write your converter: https://www.jooq.org/doc/latest/manual/code-generation/custom-data-types/
Be careful though.
Sure. "One day" is a very broad specification, so I can certainly say yes to this question
None of the issues you've mentioned should keep you from doing that. The overall gain is still magnificent if you're sure that jOOQ is a better fit than Hibernate - because these design decision are much more higher level than individual data types. Besides, from the way you phrased this, I'm sure you've already decided anyway. Hope this helps :-) |
We're definitely (finally) going to implement a new way generating DTO types in jOOQ's code generator, perhaps even replacing the term POJO (whose J means Java) by DTO in generated package names and API. The main issue here is #3821, in whose context Kotlin data classes will also be supported. No existing logic will be removed, it will just be reorganised to better allow for further extensions, like this one. |
@lukaseder - any update on the Kotlin data class for pojos? Is that a part of the 3.13 release? |
Haha, promises... Every. Single. Time. Why do I keep making them? No, this is not part of any release yet. I recognise a lot of people want this. |
In the meantime, I've invested some time in a new Any feedback in that area that you folks may have is very welcome! |
I will address this now for jOOQ 3.14 via #6248. I don't think that generating data classes in isolation makes sense. I'd like to offer the same feature set as for Scala, a complete |
Implemented via #6248 (push to github pending) |
A nice feature when implementing an entire I mean, why not: ctx.batchStore(
BookRecord(id = 1, title = "Effective jOOQ")
BookRecord(id = 2, title = "Just use SQL")
) |
When generating Kotlin data classes with optional parameters, such as: data class T(
val i: Int? = null
, val j: String? = null
) Then, the existing |
There will be a flag to opt out of this in the |
I found #3883 today, so I hope there is something going on at this point. I found it nearly impossible to implement a jooq generated interface with a kotlin data class (compiler conflicts on the overriden get/set methods).
For Kotlin users it would be great if one could work with gererated kotlin data classes.
The text was updated successfully, but these errors were encountered: