In some JPA annotations I want to use field names directly in code in place of error-prone strings:
@javax.persistence.OrderBy(value = User_.registrationDate.getName())
public List<PlugConfig> getPlugConfigs() { ... }
But the above won’t compile because to get name I have to use function that is not constant expression (User_ is generated JPA @StaticMetamodel).
Is it possible to use metamodel for this in any way or have I stick to direct string constants? Is there any way to automatically generate such string constants for metamodel? (I am using maven-processor-plugin for generation)
I haven’t tried but from what I’ve read in a completly other context (not JPA) you could try:
E.g.
It’s just a thought. I don’t know if it fits in this case.