Skip to content

proposed fixes to Query API #4516

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

Merged
merged 5 commits into from
Dec 27, 2021
Merged

Conversation

gavinking
Copy link
Member

The main goal of this work is to alleviate the problem of warning in the client program resulting from invocations of raw Querys returned by Hibernate Session methods.

This is a difficult problem due to the requirements of backward compatibility with ancient versions of Hibernate, and due to the inheritance from EntityManager which still uses raw types.

As discussed, I have:

  • Preferred the use of @SuppressWarnings("rawtypes") to wildcards <?> in methods of Query.
  • @Deprecated createXxxxQuery() methods which accept no class.
  • improved the createNativeQuery() methods with additional overloads, and the ability to accept a non-entity result class.

This solution is imperfect, but it's at least an improvement.

@hibernate hibernate deleted a comment from hibernate-github-bot bot Dec 24, 2021
@gavinking gavinking added the 6.0 label Dec 24, 2021
@gavinking gavinking requested a review from sebersole December 24, 2021 12:14
I hate doing this but it's necessary since Query is often
used as a raw type, and the wildcards result in additional
compiler warnings at the usage site

Also clean up some other warnings I encountered in this code
- and add a second new overload
- tolerate non-entity classes as arguments to these methods
- the overloads accept a result class, and return a typed Query<R>
@gavinking gavinking force-pushed the no-wildcards-in-query branch from 4b52f6f to ce1697f Compare December 27, 2021 20:18
@hibernate hibernate deleted a comment from hibernate-github-bot bot Dec 27, 2021
@gavinking gavinking merged commit 0b2a357 into hibernate:main Dec 27, 2021
@gavinking gavinking deleted the no-wildcards-in-query branch June 15, 2023 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants