Skip to content

Commit

Permalink
Remove exception guard for absent query handling.
Browse files Browse the repository at this point in the history
We now no longer fall back to an absent query when a NamedQuery construction fails with IllegalArgumentException. IllegalArgumentException is also used by the JPA API to indicate an absent query. In other cases, where we fail with IllegalArgumentException, we fell back to query derivation as handling IAE as signal for an absent query.

We already have better query absence checks in place so we can remove the try/catch blocks in favor of the named query presence check.

Closes #3550
  • Loading branch information
mp911de committed Aug 1, 2024
1 parent 7b2ae0e commit 398b82b
Showing 1 changed file with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static boolean hasNamedQuery(EntityManager em, String queryName) {
@Nullable
public static RepositoryQuery lookupFrom(JpaQueryMethod method, EntityManager em) {

final String queryName = method.getNamedQueryName();
String queryName = method.getNamedQueryName();

if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Looking up named query %s", queryName));
Expand All @@ -143,16 +143,11 @@ public static RepositoryQuery lookupFrom(JpaQueryMethod method, EntityManager em
throw QueryCreationException.create(method, "Scroll queries are not supported using String-based queries");
}

try {

RepositoryQuery query = new NamedQuery(method, em);
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Found named query %s", queryName));
}
return query;
} catch (IllegalArgumentException e) {
return null;
RepositoryQuery query = new NamedQuery(method, em);
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Found named query %s", queryName));
}
return query;
}

@Override
Expand Down

0 comments on commit 398b82b

Please sign in to comment.