-
Notifications
You must be signed in to change notification settings - Fork 28
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
Proposal for Criteria Feature in Jakarta Data[Vote] #460
Comments
seems specific to JPA criteria |
A pattern like this is something to consider post v1.0 when more is added to the static metamodel to better enable it. |
Agreed. This isn't something I would bite off for 1.0. I think really it's tricky to get right. (Speaking from hard experience here.) |
By the way, since this issue is open, I just want to record for the future that @njr-11 has proposed something that I think is really nice, in some ways quite a lot nicer than a "full" criteria query API. The idea is to use the static metamodel to express "restrictions" which can be passed to a repository methods. Conceptually, something like this: repo.books(_Book.title.like("Jakarta Data%"),
_Book.publicationDate.between(pastDate, LocalDate.now())) Or, if you need to combine this with ordering: repo.books(where(_Book.title.like("Jakarta Data%"),
_Book.publicationDate.between(pastDate, LocalDate.now())),
by(_Book.title.ascIgnoreCase(),_Book.isbn.asc()))) [Don't focus on the details here, I know @njr-11 has thought about this longer than I have and surely has more-developed ideas about it.] Of course, this is much less expressive than a real criteria API. But:
Now, on the other hand, it's also completely compatible with a full criteria API, it's not really in competition at all. The objects returned by Anyway, I would love to have this, and I think users would stampede for something like it. |
That is nice! |
I wonder if it might be helpful to look at how go-jet approaches this? |
As a ...
I need to be able to ...
Expanding upon the capabilities of the Jakarta Data Query Language (#458), this proposal introduces the Criteria feature to enable programmatically constructing queries within the Jakarta Data framework. The Criteria API provides developers with an object-oriented approach to building query criteria, offering greater flexibility and control over data retrieval operations.
Which enables me to ...
The primary goal of this proposal is to initiate a discussion and a vote regarding the inclusion of the Criteria feature in the Jakarta Data project.
Key Features:
Programmatic Query Construction: The Criteria API allows developers to programmatically build query criteria using a fluent and object-oriented interface, eliminating the need for raw queries.
Filtering and Logical Conditions: Developers can apply various filtration rules and logical conditions to the criteria query object, enabling precise data retrieval based on specific criteria.
Integration with Jakarta Data Query Language: The Criteria feature seamlessly integrates with the Jakarta Data Query Language, providing an additional method for constructing queries within the framework.
Integration with Metadata: Criteria queries can be combined with metadata-driven queries, offering developers multiple options for constructing queries based on their requirements.
Integration with Repository: Introducing a new interface,
CriteriaRepository,
that extends the existingPageableRepository,
and enables seamless integration of criteria-based queries with repository pattern implementations.Additional information
Example Usage:
Benefits:
Simplified Query Construction: The Criteria API simplifies query construction by providing a fluent and object-oriented interface, reducing the complexity of query writing.
Enhanced Flexibility: Developers have greater flexibility in defining query criteria programmatically, allowing for dynamic and adaptable data retrieval operations.
Integration with Metadata and Query Language: The Criteria feature seamlessly integrates with metadata-driven queries and the Jakarta Data Query Language, providing a comprehensive solution for data access within the Jakarta Data framework.
Repository Integration: The introduction of
CriteriaRepository
enables developers to leverage criteria-based queries within the repository pattern, promoting code organization and reusability.The text was updated successfully, but these errors were encountered: