{"record":{"id":"ce5d5001c3bee0b8","repo":"hibernate/hibernate-orm","slug":"escape-may-not-be-used-with-like-regexp","errorCode":null,"errorMessage":"'ESCAPE' may not be used with 'LIKE REGEXP'","messagePattern":"'ESCAPE' may not be used with 'LIKE REGEXP'","errorType":"exception","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java","lineNumber":3266,"sourceCode":"\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tfinal var ordinalityColumnContext\n\t\t\t\t\t\t= (HqlParser.XmlTableOrdinalityColumnContext) columnContext;\n\t\t\t\txmlTable.ordinalityColumn( visitIdentifier( ordinalityColumnContext.identifier() ) );\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic SqmPredicate visitLikePredicate(HqlParser.LikePredicateContext ctx) {\n\t\tfinal boolean negated = ctx.NOT() != null;\n\t\tfinal boolean caseSensitive = ctx.LIKE() != null;\n\t\tfinal var expression = (SqmExpression<?>) ctx.expression( 0 ).accept( this );\n\t\tfinal var pattern = (SqmExpression<?>) ctx.expression( 1 ).accept( this );\n\t\tif ( ctx.REGEXP() != null ) {\n\t\t\tif ( ctx.likeEscape() != null ) {\n\t\t\t\tthrow new SemanticException( \"'ESCAPE' may not be used with 'LIKE REGEXP'\", query );\n\t\t\t}\n\t\t\treturn new SqmBooleanExpressionPredicate(\n\t\t\t\t\tgetFunctionDescriptor( \"regexp_like\" )\n\t\t\t\t\t\t\t.generateSqmExpression(\n\t\t\t\t\t\t\t\t\tcaseSensitive\n\t\t\t\t\t\t\t\t\t\t\t? asList( expression, pattern )\n\t\t\t\t\t\t\t\t\t\t\t: asList( expression, pattern,\n\t\t\t\t\t\t\t\t\t\t\t\t\tnew SqmLiteral<>( \"i\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnodeBuilder().getStringType(),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnodeBuilder()\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\t\tqueryEngine()\n\t\t\t\t\t\t\t),\n\t\t\t\t\tnegated,\n\t\t\t\t\tnodeBuilder()\n\t\t\t);","sourceCodeStart":3248,"sourceCodeEnd":3284,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java#L3248-L3284","documentation":"Error \"'ESCAPE' may not be used with 'LIKE REGEXP'\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A runtime precondition of the Hibernate API is violated.","commonSituations":"Occurs when application code or configuration does not satisfy the documented contract of the API being called.","solutions":["Remove the ESCAPE clause from the LIKE REGEXP predicate.","Use a plain LIKE if escape handling is required."],"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"}