hibernate/hibernate-orm · error · ConnectionProviderConfigurationException

Could not configure c3p0: " + e.getMessage()

Error message

Could not configure c3p0: " + e.getMessage()

What it means

getSortExpressions(...) reads the select-item indexes recorded on the SortSpecification when the SQL AST node was built. This IllegalStateException is a defensive internal check claiming the indexes array is null; in the current code the field is final and always computed in the constructor from the sort expression, so a null can only come from a hand-built or mutated SortSpecification outside the normal SQM-to-SQL pipeline. Treat it as framework-internal corruption, not a query-authoring mistake.

Source

Thrown at hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/C3P0ConnectionProvider.java:232

							DEFAULT_MAX_POOL_SIZE ),
					fetchSize
			);
			if ( !connection.getAutoCommit() ) {
				connection.rollback();
			}
		}
		catch (SQLException e) {
			throw new JDBCConnectionException( "Could not create connection", e );
		}
	}

	private DataSource createDataSource(String jdbcUrl, Properties connectionProps, Map<String, Object> poolProperties) {
		try {
			return pooledDataSource( unpooledDataSource( jdbcUrl, connectionProps ), poolProperties );
		}
		catch (Exception e) {
			CONNECTION_INFO_LOGGER.unableToInstantiateConnectionPool( e );
			throw new ConnectionProviderConfigurationException(
					"Could not configure c3p0: " + e.getMessage(),  e );
		}
	}

	private void loadDriverClass(String jdbcDriverClass) {
		if ( jdbcDriverClass == null ) {
			CONNECTION_INFO_LOGGER.jdbcDriverNotSpecified();
		}
		else {
			try {
				serviceRegistry.requireService( ClassLoaderService.class ).classForName( jdbcDriverClass );
			}
			catch (ClassLoadingException e) {
				throw new ClassLoadingException( "JDBC Driver class " + jdbcDriverClass + " not found", e );
			}
		}
	}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Upgrade Hibernate - the indexes contract changed across 6.x/7.x and bugs here get fixed.
  2. If you build SortSpecification yourself, construct it from an expression that wraps a SqlSelectionExpression so indexes are derived, or via the public constructors only.
  3. Avoid mutating SQL AST nodes after the translator receives them.
  4. Report to HHH with the stack trace if no custom AST code is involved.
Defensive patterns

Strategy: try-catch

Try / catch

try {
    return query.getResultList();
} catch ( IllegalStateException e ) {
    if ( e.getMessage() != null && e.getMessage().contains("missing selection indexes") ) {
        // framework-internal: capture mapping + query and file an HHH issue
        logHibernateIssue( e, currentQuery );
        throw e;
    }
    throw e;
}

Prevention

When it happens

Trigger: Custom code constructing SortSpecification subclasses or replacing sort expressions after construction and then running the query through full-join emulation (MySQL/MariaDB/Sybase/H2/TiDB); reflection-based mutation; a Hibernate regression where a SortSpecification is created without a SqlSelectionExpression-based expression.

Common situations: Extensions that post-process the SQL AST (custom translators, auditing/rewriting layers); version upgrades that changed SortSpecification constructors; rarely, users building native SQL AST by hand.

Related errors


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