Since there's no language construct in Java to refer to a persistent property or field, string names are used.
Apart from simple example above, some more complex ones:
Creating new criteria on collection:
It seems that with some DFA and access to entity model, resolving could be provided for the property references in the Criteria API.
Of course not all scenarios can be covered, so references should be soft probably.
Even with limited support (meaning DFA has some restrictions etc), resolving (navigation/variants) for long entity property names would be a nice productivity boost.
Btw, a similar API is one of the planned features for JPA 2.0.
Since there's no language construct in Java to refer to a persistent property or field, string names are used.
Apart from simple example above, some more complex ones:
Creating new criteria on collection:
It seems that with some DFA and access to entity model, resolving could be provided for the property references in the Criteria API.
Of course not all scenarios can be covered, so references should be soft probably.
Even with limited support (meaning DFA has some restrictions etc), resolving (navigation/variants) for long entity property names would be a nice productivity boost.
Btw, a similar API is one of the planned features for JPA 2.0.
For more detail (and source or sample code above), see hibernate reference manual: Chapter 15. Criteria Queries