Skip to content
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

#589: avoid collisions in metamodel's variables #592

Merged
merged 6 commits into from
Mar 25, 2024
Merged

Conversation

lukasj
Copy link
Contributor

@lukasj lukasj commented Mar 15, 2024

fixes #589

this should also handle the case where the name of a named thing is with a dot (ie Employee.findAll)

@lukasj lukasj requested a review from gavinking March 15, 2024 13:14
@gavinking
Copy link
Contributor

@lukasj I'm not sure I like the idea of doing it for every field. I would have done it only for the fields where a collision occurs.

@lukasj
Copy link
Contributor Author

lukasj commented Mar 15, 2024

While that is certainly feasible, I like the naming consistency this (unexpectedly) brings in wrt usage of the trailing underscore - it is the same for the name of the canonical class (Cls_) and the name of the field (Cls_.ID_); with static imports this also allows one to easily recognise generated constants from user defined ones.

@gavinking
Copy link
Contributor

mmmrmrrmrmrmrrrmmmm I can live with it I guess.

@gavinking
Copy link
Contributor

Hold on a sec.

@lukasj, if we're adding a trailing _, then in principle we no longer need the upper-capitalization. We could let people write:

@OneToMany(mappedBy=Book_.publisher_)
Set<Book> books;

instead of:

@OneToMany(mappedBy=Book_.PUBLISHER_)
Set<Book> books;

WDYT?

@lukasj
Copy link
Contributor Author

lukasj commented Mar 16, 2024

well, it's public static final constant for which the java (naming) convention is to use upper-case

@gavinking
Copy link
Contributor

well, it's public static final constant for which the java (naming) convention is to use upper-case

I know, but I'm pretty sure we don't need to go to court to break that convention if it's the right thing to do.

Copy link
Contributor

@gavinking gavinking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of suggestions you can accept or ignore as you please.

@lukasj lukasj merged commit c73b77a into jakartaee:master Mar 25, 2024
2 checks passed
@lukasj lukasj deleted the 589 branch March 25, 2024 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Define behaviour for collisions in variable names in metamodel
2 participants