Skip to content

Commit

Permalink
Add SyntaxException to the NamedQueryMistake checks
Browse files Browse the repository at this point in the history
For Panache ORM and Reactive
  • Loading branch information
DavideD authored and yrodiere committed Nov 28, 2023
1 parent 0d04f2e commit f65d708
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.Map;

import org.hibernate.query.SemanticException;
import org.hibernate.query.SyntaxException;
import org.hibernate.query.sqm.ParsingException;

import io.quarkus.panache.common.exception.PanacheQueryException;

Expand Down Expand Up @@ -43,7 +45,8 @@ private static boolean isNamedQuery(String namedQuery) {

public static RuntimeException checkForNamedQueryMistake(IllegalArgumentException x, String originalQuery) {
if (originalQuery != null
&& x.getCause() instanceof SemanticException
&& (x.getCause() instanceof SemanticException || x.getCause() instanceof ParsingException
|| x.getCause() instanceof SyntaxException)
&& isNamedQuery(originalQuery)) {
return new PanacheQueryException("Invalid query '" + originalQuery
+ "' but it matches a known @NamedQuery, perhaps you should prefix it with a '#' to use it as a named query: '#"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Map;

import org.hibernate.query.SemanticException;
import org.hibernate.query.SyntaxException;
import org.hibernate.query.sqm.ParsingException;

import io.quarkus.panache.common.exception.PanacheQueryException;
Expand Down Expand Up @@ -54,7 +55,8 @@ static String getNamedQuery(String namedQuery) {

public static RuntimeException checkForNamedQueryMistake(IllegalArgumentException x, String originalQuery) {
if (originalQuery != null
&& (x.getCause() instanceof SemanticException || x.getCause() instanceof ParsingException)
&& (x.getCause() instanceof SemanticException || x.getCause() instanceof ParsingException
|| x.getCause() instanceof SyntaxException)
&& isNamedQuery(originalQuery)) {
return new PanacheQueryException("Invalid query '" + originalQuery
+ "' but it matches a known @NamedQuery, perhaps you should prefix it with a '#' to use it as a named query: '#"
Expand Down

0 comments on commit f65d708

Please sign in to comment.