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
Add code generation option to generate string constants for all object names #5210
Comments
Thank you very much for your suggestion, @slavap. You can already do this very easily by extending the All you have to do is override While I don't want to exclude adding such a feature to jOOQ, I'd like to avoid having too many generated artefacts out of the box in the generated classes. The complexity of avoiding naming collisions grows quickly, so I'm putting this issue on the long term feature requests lists. Perhaps, if other use-cases arise that would profit from this, we'll be happy to review the idea. |
Thank you for explanation! |
What if you have a prefix that collides with an existing column? E.g. I'm of course exaggerating here. From experience, however, I'm pretty sure that this feature will cause a bit of maintenance work, while not adding a lot of value for most users, which is why I'd like to collect more use-cases, first. |
Use cases are quite obvious. Anywhere you need to annotate something related to table or table fields (it could be some kind of meta information or for example hints for automatic UI construction), you have to repeat string values already presented in generated code. So there is a good chance to misspell or even getting runtime error when generated classes are changed together with db in the future. Compiler can check constants, but cannot check strings. |
I understand what you mean, but in 95% of all cases where you're not using annotations, you can get the names via |
Sure, it's mostly for annotations, getName() works fine in other places. |
We'll think of this some more. I can certainly see the value of constants every now and then. But it's a tricky thing to add in a global context. I mean:
etc. |
Thank you for considering this functionality, I understand it's not that simple, but may improve other parts of code base "outside" of jooq. |
Regarding:
Well... :) But you can't use those references in annotations... |
It could be enum :-) |
Hah! Indeed. And a column enum could contain the column string, and reference the table enum, which references the schema enum, etc. Very interesting thought, thanks! |
We'll put this on the long-term roadmap. I don't think the idea is ripe enough to be implemented. Sure, there's a short-term gain for usage of these values in annotations. But that seems like a use-case that very few people have, and if they do, they can easily extend the code generator to generate a new class like There are too many open questions (e.g. regarding qualification of such names), which might lead to either:
We'll keep this open to see if anyone else is interested in such a feature. |
There has been some traction on this issue, but not enough.
I'm closing this as "won't fix". |
Duplicate of this issue: #11375 I'm re-opening this, putting the issue on hold. The final decision on this feature hasn't been made. Prioritisation is definitely low for now. |
It's currently not in a rejected state, but also not in any prioritised state, given that an out of the box feature will take quite some effort to tackle all the edge cases (naming conflicts, generator strategies, etc.) whereas it's already quite simple for users to implement themselves, by extending the |
I would also like to be able to use table names in annotations... |
I'll implement this for jOOQ 3.19, given it gets traction time and again. There won't be much means of configuring the whereabouts of such constants, other than the usual generator strategies, keeping in mind that it's still quite simple to implement this manually by subclassing the The assumptions will be:
Tasks
|
Package UDTs generated wrong UDTNames objects, see [#10576]
Example:
It would be really nice to have:
then I can use these strings in annotations of my classes without repeating them. And code will be checked better by compiler.
The text was updated successfully, but these errors were encountered: