hibernate/hibernate-orm · error · IllegalArgumentException
Informix only supports the case insensitive flag 'i' as lite
Error message
Informix only supports the case insensitive flag 'i' as literal but got.
What it means
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.
Source
Thrown at hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/function/InformixRegexpLikeFunction.java:38
*/
public class InformixRegexpLikeFunction extends AbstractRegexpLikeFunction {
public InformixRegexpLikeFunction(TypeConfiguration typeConfiguration) {
super( typeConfiguration );
}
@Override
public void render(
SqlAppender sqlAppender,
List<? extends SqlAstNode> arguments,
ReturnableType<?> returnType,
SqlAstTranslator<?> walker) {
final boolean caseSensitive;
if ( arguments.size() > 2 ) {
if ( !(arguments.get( 2 ) instanceof Literal literal)
|| !(literal.getLiteralValue() instanceof String flags)
|| !flags.equals( "i" ) ) {
throw new IllegalArgumentException( "Informix only supports the case insensitive flag 'i' as literal but got." );
}
caseSensitive = false;
}
else {
caseSensitive = true;
}
sqlAppender.appendSql( "regex_match(" );
arguments.get( 0 ).accept( walker );
sqlAppender.appendSql( ',' );
arguments.get( 1 ).accept( walker );
if ( !caseSensitive ) {
// 1 is extended POSIX regex which is the default, 3 is extended POSIX regex and case-insensitive
// See https://www.ibm.com/docs/en/informix-servers/14.10.0?topic=routines-regex-match-function
sqlAppender.appendSql( ",3" );
}
sqlAppender.appendSql( ')' );
}View on GitHub (pinned to fad1729dce)
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
Example fix
// before
:flags bound as parameter
List<E> l = em.createQuery("select e from E e where regexp_like(e.code, :pat, :flags)", E.class)
.setParameter("pat", "^abc").setParameter("flags", "i").getResultList();
// after: literal 'i' only (or drop the argument for case-sensitive)
List<E> l = em.createQuery("select e from E e where regexp_like(e.code, :pat, 'i')", E.class)
.setParameter("pat", "^abc").getResultList(); Defensive patterns
Strategy: validation
Validate before calling
// Validate the flags argument before binding it into HQL for Informix
static String informixFlags(String flags) {
if (flags == null || flags.isEmpty()) return null; // case-sensitive default
if ("i".equals(flags)) return "'i'"; // only supported literal
throw new IllegalArgumentException("Informix regexp_like supports only literal flag 'i'");
} Try / catch
try {
return em.createQuery(hql, E.class).setParameter("flags", flags).getResultList();
} catch (IllegalArgumentException e) {
if (e.getMessage() != null && e.getMessage().contains("case insensitive flag")) {
// drop the flags parameter or hardcode 'i' and rebuild the query
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Informix does not support binary literals
- Connection lock-timeout does not accept skip-locked
- Can't emulate offset clause in subquery
- Summarization is not supported by DBMS!
- Insert conflict 'do update' clause with constraint name is n
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/f9c9c438e421f03d.
Report an issue: GitHub.