jakartaee / persistence

https://jakartaee.github.io/persistence/
Other
186 stars 55 forks source link

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

Closed lukasj closed 3 months ago

lukasj commented 3 months ago

fixes #589

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

gavinking commented 3 months ago

@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 commented 3 months ago

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 commented 3 months ago

mmmrmrrmrmrmrrrmmmm I can live with it I guess.

gavinking commented 3 months ago

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 commented 3 months ago

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

gavinking commented 3 months ago

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.