hibernate/hibernate-orm · error · ParsingException
Unrecognized trim specification
Error message
Unrecognized trim specification
What it means
Error "Unrecognized trim specification" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java:5548
null,
queryEngine()
);
}
@Override
public SqmTrimSpecification visitTrimSpecification(HqlParser.TrimSpecificationContext ctx) {
// JPA says the default is BOTH
final var trimSpec = ctx != null ? trimSpec( ctx ) : TrimSpec.BOTH;
return new SqmTrimSpecification( trimSpec, nodeBuilder() );
}
private static TrimSpec trimSpec(HqlParser.TrimSpecificationContext ctx) {
final var symbol = ((TerminalNode) ctx.getChild( 0 )).getSymbol();
return switch ( symbol.getType() ) {
case HqlParser.LEADING -> TrimSpec.LEADING;
case HqlParser.TRAILING -> TrimSpec.TRAILING;
case HqlParser.BOTH -> TrimSpec.BOTH;
default -> throw new ParsingException( "Unrecognized trim specification" );
};
}
@Override
public SqmExpression<Character> visitTrimCharacter(HqlParser.TrimCharacterContext ctx) {
final String trimCharText;
if ( ctx == null ) {
// JPA says space is the default
trimCharText = " ";
}
else {
final var parameter = ctx.parameter();
if ( parameter != null ) {
//noinspection unchecked
return (SqmExpression<Character>) parameter.accept( this );
}
else {
trimCharText = unquoteStringLiteral( ctx.getText() );View on GitHub (pinned to fad1729dce)
Solutions
- The trim specification is not recognized. Use LEADING, TRAILING, or BOTH in the trim() function.
When it happens
Trigger: An invalid keyword/field is used in a datetime, pad, or trim expression: Unrecognized trim specification
Common situations: HQL queries using extract(), pad(), or trim() with a field/specification keyword that is not one of the documented values.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/c4bfeb85a3e0b440.
Report an issue: GitHub.