hibernate/hibernate-orm · error · QueryException

The jTDS driver does not support calling functions through t

Error message

The jTDS driver does not support calling functions through the JDBC CallableStatement API

What it means

Error "The jTDS driver does not support calling functions through the JDBC CallableStatement API" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/procedure/internal/JTDSCallableStatementSupport.java:48

	public JdbcOperationQueryCall interpretCall(ProcedureCallImplementor procedureCall) {
		final String procedureName = procedureCall.getProcedureName();
		final FunctionReturnImplementor<?> functionReturn = procedureCall.getFunctionReturn();
		final ProcedureParameterMetadataImplementor parameterMetadata = procedureCall.getParameterMetadata();
		final List<? extends ProcedureParameterImplementor<?>> registrations = parameterMetadata.getRegistrationsAsList();
		final int paramStringSizeEstimate;
		if ( functionReturn == null && parameterMetadata.hasNamedParameters() ) {
			// That's just a rough estimate. I guess most params will have fewer than 8 chars on average
			paramStringSizeEstimate = registrations.size() * 12;
		}
		else {
			// For every param rendered as '?' we have a comma, hence the estimate
			paramStringSizeEstimate = registrations.size() * 2;
		}
		final JdbcCallImpl.Builder builder = new JdbcCallImpl.Builder();
		final StringBuilder buffer;
		final int offset;
		if ( functionReturn != null ) {
			throw new QueryException( "The jTDS driver does not support calling functions through the JDBC CallableStatement API" );
		}
		offset = 1;
		buffer = new StringBuilder( 9 + procedureName.length() + paramStringSizeEstimate ).append( "{call " );

		buffer.append( procedureName );

		if ( registrations.isEmpty() ) {
			buffer.append( '(' );
		}
		else {
			char sep = '(';
			for ( int i = 0; i < registrations.size(); i++ ) {
				final ProcedureParameterImplementor<?> parameter = registrations.get( i );
				if ( parameter.getMode() == ParameterMode.REF_CURSOR ) {
					throw new QueryException( "Dialect [" + procedureCall.getSession().getJdbcServices().getJdbcEnvironment().getDialect().getClass().getName() + "] not known to support REF_CURSOR parameters" );
				}
				buffer.append( sep );
				final JdbcCallParameterRegistration registration = parameter.toJdbcParameterRegistration(

View on GitHub (pinned to fad1729dce)

Solutions

  1. Switch to a driver that supports CallableStatement function calls, e.g. the Microsoft JDBC driver or jTDS with procedure syntax instead of function syntax.
  2. Call the routine as a stored procedure rather than a function.

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/2eaf8068fe3f6873. Report an issue: GitHub.