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

Clean up classes and interfaces for native queries #2045

Open
DavideD opened this issue Dec 19, 2024 · 8 comments
Open

Clean up classes and interfaces for native queries #2045

DavideD opened this issue Dec 19, 2024 · 8 comments
Labels
design A design or implementation issue
Milestone

Comments

@DavideD
Copy link
Member

DavideD commented Dec 19, 2024

I think there's is something wrong in the design of the Mutiny and Stage sessions when it comes to native queries.

For example, this Mutiny.Session#createNativeQuery returns SelectionQuery. But, it should return a ReactiveNativeQueryImplementor like in ORM.

I don't think there is a way for users to access the methods in ReactiveNativeQuery at the moment.
We need to add more testing.

(Noticed while adapting a test for HHH-18629)

@DavideD DavideD added the design A design or implementation issue label Dec 19, 2024
@DavideD DavideD added this to the 3.0.0.Beta2 milestone Dec 19, 2024
@DavideD DavideD changed the title Design of the Query interface Wrong interface returned when creating native queries Dec 19, 2024
@DavideD DavideD added the bug Something isn't working label Dec 19, 2024
@gavinking
Copy link
Member

I don't understand what you're saying here. ReactiveNativeQueryImplementor is an SPI interface. It should never be returned by any APIs. (And it isn't, AFAIK.)

@DavideD
Copy link
Member Author

DavideD commented Dec 19, 2024

Right.
I was looking at some implementation. But it should return a ReactiveNativeQuery, isn't it?

It should be similar to the QueryProducer#createNativeQuery(String sqlString, Class resultClass);

@gavinking
Copy link
Member

gavinking commented Dec 19, 2024

Things with Reactive in the name are SPI/implementation. We don't expose them to the application program.

I'm not sure why we have ReactiveNativeQuery and friends. They are probably not be needed, because Hibernate Reactive doesn't have anything like org.hibernate.query.NativeQuery. That's old old stuff that's a legacy from pre-JPA days, and that someday we will probably wind up deprecating.

@DavideD DavideD removed the bug Something isn't working label Dec 19, 2024
@gavinking
Copy link
Member

So @DavideD if you wanted to add Stage.NativeQuery and Mutiny.NativeQuery to our API, then in principle you could. But I would very much recommend against that because it would just be doubling-down on legacy stuff that we want to get away from.

@DavideD
Copy link
Member Author

DavideD commented Dec 20, 2024 via email

@gavinking
Copy link
Member

The usual way to do it since JPA 1.0 is to use a @SqlResultSetMapping, not this old stuff.

@DavideD
Copy link
Member Author

DavideD commented Dec 20, 2024

OK, then I will just keep this open as a reminder that we need to clean up this area.

@DavideD DavideD changed the title Wrong interface returned when creating native queries Clean up classes and interfaces for native queries Dec 20, 2024
@gavinking
Copy link
Member

Note that I just opened jakartaee/persistence#691 to finally have a JPA-standard way to define result set mappings programmatically. Will have to wait for JPA4 though.

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

No branches or pull requests

2 participants