{"record":{"id":"9d074dcd0b79ec25","repo":"quarkusio/quarkus","slug":"unsupported-query-type-in-query-offending-method","errorCode":null,"errorMessage":"Unsupported query type in @Query. Offending method is ${methodName} of Repository ${repositoryName}","messagePattern":"Unsupported query type in @Query\\. Offending method is (.+?) of Repository (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/generate/CustomQueryMethodsAdder.java","lineNumber":113,"sourceCode":"                verifyQueryAnnotation(queryInstance, methodName, repositoryName);\n                queryString = queryInstance.value(QUERY_VALUE_FIELD).asString().trim();\n            } else if (namedQueryInstance != null) {\n                queryString = namedQueryInstance.value(NAMED_QUERY_FIELD).asString().trim();\n            } else {\n                // handled by DerivedMethodsAdder\n                continue;\n            }\n\n            if (queryString.contains(\"#{\")) {\n                throw new IllegalArgumentException(\"spEL expressions are not currently supported. \" +\n                        \"Offending method is \" + methodName + \" of Repository \" + repositoryName);\n            }\n\n            if (!(queryString.startsWith(\"select\") || queryString.startsWith(\"SELECT\")\n                    || queryString.startsWith(\"from\") || queryString.startsWith(\"FROM\")\n                    || queryString.startsWith(\"delete\") || queryString.startsWith(\"DELETE\")\n                    || queryString.startsWith(\"update\") || queryString.startsWith(\"UPDATE\"))) {\n                throw new IllegalArgumentException(\"Unsupported query type in @Query. \" +\n                        \"Offending method is \" + methodName + \" of Repository \" + repositoryName);\n            }\n\n            List<Type> methodParameterTypes = method.parameterTypes();\n            String[] methodParameterTypesStr = new String[methodParameterTypes.size()];\n            List<Integer> queryParameterIndexes = new ArrayList<>(methodParameterTypes.size());\n            Integer pageableParameterIndex = null;\n            Integer sortParameterIndex = null;\n            for (int i = 0; i < methodParameterTypes.size(); i++) {\n                DotName parameterType = methodParameterTypes.get(i).name();\n                methodParameterTypesStr[i] = parameterType.toString();\n                if (DotNames.SPRING_DATA_PAGEABLE.equals(parameterType)\n                        || DotNames.SPRING_DATA_PAGE_REQUEST.equals(parameterType)) {\n                    if (pageableParameterIndex != null) {\n                        throw new IllegalArgumentException(\"Method \" + method.name() + \" of Repository \" + repositoryClassInfo\n                                + \"has invalid parameters - only a single parameter of type\" + DotNames.SPRING_DATA_PAGEABLE\n                                + \" can be specified\");\n                    }","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/generate/CustomQueryMethodsAdder.java#L95-L131","documentation":"The @Query string must start with select/from/delete/update (case-insensitive) so Quarkus can classify it as a read or modifying query. Anything else (e.g. native SQL comments, WITH clauses for CTEs, or misspelled keywords) cannot be handled and fails the build with this IllegalArgumentException.","triggerScenarios":"@Query whose value starts with something other than select/from/delete/update: leading whitespace or newline, a SQL comment (-- or /*), a CTE like WITH ..., a misspelled keyword (e.g. 'SELEC'), or an empty string with only a nativeQuery.","commonSituations":"Multi-line query strings where the first line is a comment; CTE queries (WITH temp AS (...)) ported from SQL; queries with leading blank lines or indentation from code formatting; using nativeQuery=true with vendor-specific prefixes.","solutions":["Ensure the query string literally starts with SELECT/FROM/DELETE/UPDATE (case-insensitive) with no leading whitespace or comments","Move CTE (WITH ...) queries into a named stored procedure or restructure to avoid the WITH clause","Strip SQL comments from the @Query value","Log/print the annotation value if unsure what the string actually starts with"],"exampleFix":"// before\n@Query(\"-- active users\\nselect u from User u where u.active = true\")\n// after\n@Query(\"select u from User u where u.active = true\")","handlingStrategy":"validation","validationCode":"String q = query == null ? \"\" : query.trim();\nboolean ok = q.matches(\"(?i)^(select|from|delete|update).*\");\nif (!ok) throw new IllegalArgumentException(\"@Query must start with select/from/delete/update: \" + q);","typeGuard":null,"tryCatchPattern":"try {\n    compile();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Unsupported query type in @Query\")) {\n        log.error(\"Inspect the first characters of the @Query string\");\n    }\n    throw e;\n}","preventionTips":["Ensure no leading whitespace, newlines, or SQL comments in @Query","Avoid WITH/CTE clauses in @Query on Quarkus","Check for typos in the leading keyword","Keep queries on a single line starting with the verb"],"tags":["spring-data-jpa","quarkus","jpql","query-parsing","build-time"],"backgroundTag":"unsupported-query-syntax","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}