Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Use Case]: Statically specify First/Limit at dev time so that singular return type can be valid on methods #532

Open
2 of 4 tasks
njr-11 opened this issue Mar 8, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@njr-11
Copy link
Contributor

njr-11 commented Mar 8, 2024

As a ...

  • Application user/user of the configuration itself
  • API user (application developer)
  • SPI user (container or runtime developer)
  • Specification implementer

I need to be able to ...

statically specify a limit at development time

Which enables me to ...

write a repository method with a singular return type (Optional<MyEntity> or MyEntity).

Additional information

This is currently only possible (and awkwardly so) with Query by Method Name.

To allow it with @Query and parameter based queries (@Find), we can add First (proposed by Gavin in #530 (comment))

@Find @First
@OrderBy(value = _Employee.SALARY, descending = true)
@OrderBy(value = _Employee.ID)
Optional<Employee> highestPaid(String jobTitle);

The value would default to 1.

Reminder to update recommendations in NonUniqueResultException once we have this.

This is being proposed for after Jakarta Data version 1.0.

@njr-11 njr-11 added the enhancement New feature or request label Mar 8, 2024
@njr-11 njr-11 added this to the Jakarta Data Future milestone Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant