{"record":{"id":"f9c9c438e421f03d","repo":"hibernate/hibernate-orm","slug":"informix-only-supports-the-case-insensitive-flag","errorCode":null,"errorMessage":"Informix only supports the case insensitive flag 'i' as literal but got.","messagePattern":"Informix only supports the case insensitive flag 'i' as literal but got\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/function/InformixRegexpLikeFunction.java","lineNumber":38,"sourceCode":" */\npublic class InformixRegexpLikeFunction extends AbstractRegexpLikeFunction {\n\n\tpublic InformixRegexpLikeFunction(TypeConfiguration typeConfiguration) {\n\t\tsuper( typeConfiguration );\n\t}\n\n\t@Override\n\tpublic void render(\n\t\t\tSqlAppender sqlAppender,\n\t\t\tList<? extends SqlAstNode> arguments,\n\t\t\tReturnableType<?> returnType,\n\t\t\tSqlAstTranslator<?> walker) {\n\t\tfinal boolean caseSensitive;\n\t\tif ( arguments.size() > 2 ) {\n\t\t\tif ( !(arguments.get( 2 ) instanceof Literal literal)\n\t\t\t\t|| !(literal.getLiteralValue() instanceof String flags)\n\t\t\t\t|| !flags.equals( \"i\" ) ) {\n\t\t\t\tthrow new IllegalArgumentException( \"Informix only supports the case insensitive flag 'i' as literal but got.\" );\n\t\t\t}\n\t\t\tcaseSensitive = false;\n\t\t}\n\t\telse {\n\t\t\tcaseSensitive = true;\n\t\t}\n\n\t\tsqlAppender.appendSql( \"regex_match(\" );\n\t\targuments.get( 0 ).accept( walker );\n\t\tsqlAppender.appendSql( ',' );\n\t\targuments.get( 1 ).accept( walker );\n\t\tif ( !caseSensitive ) {\n\t\t\t// 1 is extended POSIX regex which is the default, 3 is extended POSIX regex and case-insensitive\n\t\t\t// See https://www.ibm.com/docs/en/informix-servers/14.10.0?topic=routines-regex-match-function\n\t\t\tsqlAppender.appendSql( \",3\" );\n\t\t}\n\t\tsqlAppender.appendSql( ')' );\n\t}","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/function/InformixRegexpLikeFunction.java#L20-L56","documentation":"Informix's regex_match can only be rendered with case-insensitivity toggled; InformixRegexpLikeFunction accepts a third flags argument only when it is the string literal 'i'. Any other flag literal ('c', 'm', 'x', or combinations like 'im') or a non-literal flags argument (bind parameter or expression) makes render() throw IllegalArgumentException before any SQL is generated.","triggerScenarios":"HQL `regexp_like(e.name, '^abc', 'c')`, combined flags like 'im', or a bound flags parameter (`regexp_like(e.name, :pat, :flags)`) with InformixDialect. Two-argument calls work fine.","commonSituations":"Reusable query fragments shared across databases where other dialects accept the full flag set; dynamic queries that bind flags as a parameter to avoid recompiling.","solutions":["Pass only the literal 'i' when case-insensitive matching is needed, or omit the third argument entirely","Encode case-sensitivity in the pattern itself (character classes like [a-zA-Z]) instead of flags","Build per-dialect HQL variants so Informix never receives unsupported flags","Use a native query when richer flags are genuinely required"],"exampleFix":"// before\n:flags bound as parameter\nList<E> l = em.createQuery(\"select e from E e where regexp_like(e.code, :pat, :flags)\", E.class)\n    .setParameter(\"pat\", \"^abc\").setParameter(\"flags\", \"i\").getResultList();\n\n// after: literal 'i' only (or drop the argument for case-sensitive)\nList<E> l = em.createQuery(\"select e from E e where regexp_like(e.code, :pat, 'i')\", E.class)\n    .setParameter(\"pat\", \"^abc\").getResultList();","handlingStrategy":"validation","validationCode":"// Validate the flags argument before binding it into HQL for Informix\nstatic String informixFlags(String flags) {\n    if (flags == null || flags.isEmpty()) return null;       // case-sensitive default\n    if (\"i\".equals(flags)) return \"'i'\";                     // only supported literal\n    throw new IllegalArgumentException(\"Informix regexp_like supports only literal flag 'i'\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    return em.createQuery(hql, E.class).setParameter(\"flags\", flags).getResultList();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"case insensitive flag\")) {\n        // drop the flags parameter or hardcode 'i' and rebuild the query\n    }\n    throw e;\n}","preventionTips":["On Informix, never bind flags as a parameter — use the literal 'i' or omit the argument","Encode multi-flag semantics in the regex pattern itself","Keep a per-dialect query builder for regexp_like"],"tags":["hibernate","informix","regexp-like","flags","illegal-argument"],"backgroundTag":"regex-function-flags-unsupported","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}