hibernate/hibernate-orm · error · SemanticException

Pad character for pad() function must be single character, f

Error message

Pad character for pad() function must be single character, found '{padCharText}'

What it means

Error "Pad character for pad() function must be single character, found '{padCharText}'" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java:5510

				queryEngine()
		);
	}

	@Override
	public SqmTrimSpecification visitPadSpecification(HqlParser.PadSpecificationContext ctx) {
		final var symbol = ((TerminalNode) ctx.getChild( 0 )).getSymbol();
		return switch ( symbol.getType() ) {
			case HqlParser.LEADING -> new SqmTrimSpecification( TrimSpec.LEADING, nodeBuilder() );
			case HqlParser.TRAILING -> new SqmTrimSpecification( TrimSpec.TRAILING, nodeBuilder() );
			default -> throw new ParsingException( "Unsupported pad specification [" + ctx.getText() + "]" );
		};
	}

	@Override
	public SqmLiteral<Character> visitPadCharacter(HqlParser.PadCharacterContext ctx) {
		final String padCharText = ctx.STRING_LITERAL().getText();
		if ( padCharText.length() != 3 ) {
			throw new SemanticException( "Pad character for pad() function must be single character, found '"
					+ padCharText + "'",
					query );
		}
		return new SqmLiteral<>(
				padCharText.charAt( 1 ),
				nodeBuilder().getCharacterType(),
				nodeBuilder()
		);
	}

	@Override
	public SqmExpression<?> visitTrimFunction(HqlParser.TrimFunctionContext ctx) {
		final var source = (SqmExpression<?>) ctx.expression().accept( this );
		return getFunctionDescriptor("trim").generateSqmExpression(
				asList(
						visitTrimSpecification( ctx.trimSpecification() ),
						visitTrimCharacter( ctx.trimCharacter() ),
						source

View on GitHub (pinned to fad1729dce)

Solutions

  1. The pad character argument of pad() must be exactly one character. Pass a single-character string literal as the pad character.

When it happens

Trigger: A multi-character literal is passed where a single character is required: Pad character for pad() function must be single character, found '<value>'

Common situations: Calling pad() or trim() in HQL with a pad/trim character literal longer than one character.


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/07a62cc0b4af50a3. Report an issue: GitHub.