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

Prototype a query by name method parser #523

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

starksm64
Copy link
Contributor

This prototypes a library tool that parses a Query by name method name using an Antlr4 generated parser and a grammar based on the current spec "BNF Grammar for Query Methods" section.

@starksm64 starksm64 marked this pull request as draft March 6, 2024 10:02
@starksm64
Copy link
Contributor Author

This has been updated to the latest code we are using to pass the TCK with Hibernate 6.6.0

@starksm64 starksm64 marked this pull request as ready for review April 18, 2024 05:26
@gavinking
Copy link
Contributor

This has been updated to the latest code we are using to pass the TCK with Hibernate 6.6.0

Awesome.

I hope everyone understands that this is something essentially any implementor of Jakarta Data can use to add support for QbMN.

Set<? extends Element> repositories = roundEnv.getElementsAnnotatedWith(Repository.class);
for (Element repository : repositories) {
String provider = repository.getAnnotation(Repository.class).provider();
if(provider.isEmpty() || provider.equalsIgnoreCase("hibernate")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope everyone understands that this is something essentially any implementor of Jakarta Data can use to add support for QbMN.

Would this restrict the the use case of this tool to hibernate only?

I'd be interested in a README file to help understand the general use case of this tool for a Jakarta Data provider.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, that should be parameterized I guess.

@starksm64
Copy link
Contributor Author

I'll add a README and a parameterization of the provider value(s). The README can have sections for providers that have made use of it to document how it is used.

@KyleAure KyleAure added this to the Jakarta Data Future milestone Apr 22, 2024
@Tomas-Kraus
Copy link

Tomas-Kraus commented May 8, 2024

Well, query method by name is regular grammar, something, that should be parsed by regular expression or state machine. Why to build this whole LL(k) context-freee grammar monster which needes at least recursive descend parser?
I solved this just using AntLR 4 lexer grammar with few states.

It's nice to have some sample QbMN parser and some additional tooling, but keep in mind that this is specification + API project.
Support libraries and additional tooling should have their own project(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants