hibernate/hibernate-orm · error · SemanticException
Escape character literals must have exactly a single charact
Error message
Escape character literals must have exactly a single character, but found: {} What it means
Error "Escape character literals must have exactly a single character, but found: {}" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java:3321
);
}
}
@Override
public Object visitLikeEscape(HqlParser.LikeEscapeContext ctx) {
final var parameter = ctx.parameter();
final var characterType = nodeBuilder().getCharacterType();
if ( parameter instanceof HqlParser.NamedParameterContext namedParameterContext ) {
return visitNamedParameter( namedParameterContext, characterType );
}
else if ( parameter instanceof HqlParser.PositionalParameterContext positionalParameterContext ) {
return visitPositionalParameter( positionalParameterContext, characterType );
}
else {
final var terminalNode = (TerminalNode) ctx.getChild( 1 );
final String escape = unquoteStringLiteral( terminalNode.getText() );
if ( escape.length() != 1 ) {
throw new SemanticException(
"Escape character literals must have exactly a single character, but found: " + escape,
query
);
}
return new SqmLiteral<>( escape.charAt( 0 ), characterType, nodeBuilder() );
}
}
@Override
public SqmPredicate visitMemberOfPredicate(HqlParser.MemberOfPredicateContext ctx) {
final boolean negated = ctx.NOT() != null;
if ( consumeDomainPath( ctx.path() )
instanceof SqmPluralValuedSimplePath<?> pluralValuedSimplePath ) {
return new SqmMemberOfPredicate(
(SqmExpression<?>) ctx.expression().accept( this ),
pluralValuedSimplePath,
negated,
nodeBuilder()View on GitHub (pinned to fad1729dce)
Solutions
- Use a single-character escape literal in the ESCAPE clause.
- Fix the escape string length.
When it happens
Trigger: A runtime precondition of the Hibernate API is violated.
Common situations: Occurs when application code or configuration does not satisfy the documented contract of the API being called.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/74cfac0c7f3b818f.
Report an issue: GitHub.