jakartaee / persistence

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

Define behaviour for collisions in variable names in metamodel #589

Closed lukasj closed 3 months ago

lukasj commented 3 months ago

right now in 3.2, there we have:

For every persistent attribute y declared by class X, the metamodel class must contain a field declaration as follows: public static final String Y = "y"; where the field name Y is obtained by transforming each lowercase character in the attribute name y to uppercase, and inserting > an underscore if the character following the transformed character is uppercase.

and later:

For every persistent non-collection-valued attribute y declared by class X, where the type of y is Y, the metamodel class must contain a declaration as follows: public static volatile SingularAttribute<X, Y> y;

so if one has an entity with an attribute name in an uppercase - there might be valid usecases for this (an example I've noticed can be a variable called IQ), then this leads to collisions. We should either change the newly added requirement for the fieldname to ie public static final String Y_ = "y"; (add an underscore, or sth else, to the variable name) or say, that we do not handle collisions, or say that the latter is in lowercase (right now it is silent, so my expectation is that the variable name is taken as it is)

gavinking commented 3 months ago

We should either change the newly added requirement for the fieldname to ie public static final String Y_ = "y";

This looks OK to me.