Skip to content

Commit 8a95dba

Browse files
committed
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
1 parent c7e3242 commit 8a95dba

File tree

1 file changed

+5
-10
lines changed
  • spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query

1 file changed

+5
-10
lines changed

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/NamedQuery.java

+5-10
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static boolean hasNamedQuery(EntityManager em, String queryName) {
130130
@Nullable
131131
public static RepositoryQuery lookupFrom(JpaQueryMethod method, EntityManager em) {
132132

133-
final String queryName = method.getNamedQueryName();
133+
String queryName = method.getNamedQueryName();
134134

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

147-
try {
148-
149-
RepositoryQuery query = new NamedQuery(method, em);
150-
if (LOG.isDebugEnabled()) {
151-
LOG.debug(String.format("Found named query %s", queryName));
152-
}
153-
return query;
154-
} catch (IllegalArgumentException e) {
155-
return null;
147+
RepositoryQuery query = new NamedQuery(method, em);
148+
if (LOG.isDebugEnabled()) {
149+
LOG.debug(String.format("Found named query %s", queryName));
156150
}
151+
return query;
157152
}
158153

159154
@Override

0 commit comments

Comments
 (0)