[clarification]: Restricting Usage of @OrderBy
Annotation to Enhance Clarity and Consistency in Jakarta Data
#618
Labels
question
Further information is requested
Specification
https://github.com/jakartaee/data/blob/main/spec/src/main/asciidoc/repository.asciidoc
I need clarification on ...
Restricting Usage of
@OrderBy
Annotation to Enhance Clarity and Consistency in Jakarta DataThe
@OrderBy
annotation in Jakarta Data is currently flexible, allowing it to be combined with various types of query definitions, including the@Query
annotation, method query names, and the@Find
annotation. While this flexibility offers a broad range of application, it introduces ambiguity, particularly regarding the precedence and interpretation of ordering instructions when multiple sources of order definitions are present. This ambiguity is manageable when thoroughly documented; however, it compromises intuitiveness and clarity in practice, making the code harder to read and understand at a glance, especially for new developers or those not intimately familiar with the specific documentation.Even with the clear documentation, reading the code is not clear what is the proper result or which one goes first in this case:
Examples of Current Implementation:
Proposed Implementation:
Under the proposed change,
@OrderBy
would be restricted to use with the@Find
annotation only, as demonstrated below:Rationale:
@OrderBy
to@Find
annotations simplifies understanding and implementing ordered queries, reducing potential errors and confusion.@OrderBy
usage makes it easier for developers to predict how their queries will behave and in what order results will be returned.Additional information
No response
The text was updated successfully, but these errors were encountered: