Add additional null checks when applying hints.

It's possible to apply hints and hit a NullPointerException.

Resolves #2716.
This commit is contained in:
Greg L. Turnquist
2022-12-05 12:28:31 -06:00
parent f40b39c3ec
commit b0aa2b6754

View File

@@ -832,6 +832,10 @@ public class SimpleJpaRepository<T, ID> implements JpaRepositoryImplementation<T
private void applyQueryHints(Query query) {
if (metadata == null) {
return;
}
getQueryHints().withFetchGraphs(em).forEach(query::setHint);
if (metadata.getComment() != null && provider.getCommentHintKey() != null) {
@@ -852,6 +856,10 @@ public class SimpleJpaRepository<T, ID> implements JpaRepositoryImplementation<T
private void applyQueryHintsForCount(Query query) {
if (metadata == null) {
return;
}
getQueryHintsForCount().forEach(query::setHint);
if (metadata.getComment() != null && provider.getCommentHintKey() != null) {