Remove exception guard for absent query handling.

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
This commit is contained in:
Mark Paluch
2024-08-01 10:17:03 +02:00
parent c7e324286f
commit 8a95dba706

View File

@@ -130,7 +130,7 @@ final class NamedQuery extends AbstractJpaQuery {
@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));
@@ -144,16 +144,11 @@ final class NamedQuery extends AbstractJpaQuery {
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