{"record":{"id":"ac71b920acd3b60a","repo":"hibernate/hibernate-orm","slug":"reserved-word-used-as-alias","errorCode":"RESERVED_WORD_USED_AS_ALIAS","errorMessage":"Strict JPQL compliance was violated : %s [%s]","messagePattern":"Strict JPQL compliance was violated : (.+?) \\[(.+?)\\]","errorType":"exception","errorClass":"StrictJpaComplianceViolation","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/hql/internal/SqmTreeCreationHelper.java","lineNumber":220,"sourceCode":"\t\t\t\tcheckJpaCompliance( sqmBuilder, identifierContext.getStart() );\n\t\t\t\treturn sqmBuilder.visitIdentifier( identifierContext );\n\t\t\t}\n\t\t\telse if ( lastChild instanceof HqlParser.NakedIdentifierContext identifierContext ) {\n\t\t\t\t// in this branch, the alias could be a reserved word (\"keyword as identifier\")\n\t\t\t\t// which JPA disallows...\n\t\t\t\tcheckJpaCompliance( sqmBuilder, identifierContext.getStart() );\n\t\t\t\treturn sqmBuilder.visitNakedIdentifier( identifierContext );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new AssertionFailure( \"Unexpected type parse of tree\" );\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static void checkJpaCompliance(SemanticQueryBuilder<?> sqmBuilder, Token identificationVariable) {\n\t\tif ( sqmBuilder.getCreationOptions().useStrictJpaCompliance() ) {\n\t\t\tif ( RESERVED_WORDS.contains( identificationVariable.getText().toLowerCase( Locale.ENGLISH ) ) ) {\n\t\t\t\tthrow new StrictJpaComplianceViolation(\n\t\t\t\t\t\tString.format(\n\t\t\t\t\t\t\t\tLocale.ROOT,\n\t\t\t\t\t\t\t\t\"Strict JPQL compliance was violated : %s [%s]\",\n\t\t\t\t\t\t\t\tStrictJpaComplianceViolation.Type.RESERVED_WORD_USED_AS_ALIAS.description(),\n\t\t\t\t\t\t\t\tidentificationVariable.getText()\n\t\t\t\t\t\t),\n\t\t\t\t\t\tStrictJpaComplianceViolation.Type.RESERVED_WORD_USED_AS_ALIAS\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Handle JPA requirement that variables (aliases) be case-insensitive\n\t */\n\tpublic static String applyJpaCompliance(String text, SemanticQueryBuilder<?> sqmBuilder) {\n\t\treturn text != null\n\t\t\t&& sqmBuilder.getCreationOptions().useStrictJpaCompliance()","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SqmTreeCreationHelper.java#L202-L238","documentation":"Error \"Strict JPQL compliance was violated : %s [%s]\" thrown in hibernate/hibernate-orm.","triggerScenarios":"An HQL-specific construct is used while strict JPQL compliance is enabled: Strict JPQL compliance was violated : <value> [<value>]","commonSituations":"Applications running with hibernate.jpa.compliance.query=true (or JPA-compliance mode) that submit queries using Hibernate extensions such as collations, tuples/row value constructors, HQL collection functions (maxelement/elements/indices), value()/key() on non-Map types, or non-standard function calls without FUNCTION() syntax.","solutions":["The query uses HQL extensions while strict JPQL compliance was requested. Rewrite the query in portable JPQL or disable strict compliance checking."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}