hibernate/hibernate-orm · error · ClassLoadingException

JDBC Driver class " + jdbcDriverClass + " not found

Error message

JDBC Driver class " + jdbcDriverClass + " not found

What it means

When ordering a union-emulated full join, Hibernate compares the number of select-item indexes recorded for a SortSpecification with the component count of the sort expression (a plain expression counts as 1; a SqlTuple counts as its parts, e.g. a composite key). This IllegalStateException fires when the tuple size changed after the indexes were computed - the constructor derives indexes from the same expression, so a mismatch implies the expression graph was rewritten between construction and rendering. It is an internal-invariant failure, typically a framework bug.

Source

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

			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 );
			}
		}
	}

	private Map<String, Object> poolSettings(Map<String, Object> hibernateProperties) {
		//swaldman 2004-02-07: modify to allow null values to signify fall through to c3p0 PoolConfig defaults
		Integer maxPoolSize = getInteger( C3P0_MAX_SIZE, hibernateProperties );
		if ( maxPoolSize == null ) {
			// if hibernate.c3p0.max_size is not specified, use hibernate.connection.pool_size
			maxPoolSize = getInteger( JdbcSettings.POOL_SIZE, hibernateProperties );
		}
		final Integer minPoolSize = getInteger( C3P0_MIN_SIZE, hibernateProperties );
		final Integer maxIdleTime = getInteger( C3P0_TIMEOUT, hibernateProperties );
		final Integer maxStatements = getInteger( C3P0_MAX_STATEMENTS, hibernateProperties );
		final Integer acquireIncrement = getInteger( C3P0_ACQUIRE_INCREMENT, hibernateProperties );
		final Integer idleTestPeriod = getInteger( C3P0_IDLE_TEST_PERIOD, hibernateProperties );

		final Map<String,Object> c3p0Properties = new HashMap<>();

View on GitHub (pinned to fad1729dce)

Solutions

  1. Order by the explicit component paths instead of the composite as a whole (e.g. order by id.part1, id.part2).
  2. Upgrade to the latest Hibernate 7.x point release - emulation tuple handling is actively fixed.
  3. Avoid the full join for composite-key ordering, or sort in a wrapping outer query.
  4. Report an HHH issue including the entity mapping with the composite id and the full join query.

Example fix

// before: ordering by the whole embedded id
"select a, b from A a full join a.bs b order by b.id"

// after: order by the tuple components explicitly
"select a, b from A a full join a.bs b order by b.id.part1, b.id.part2"
Defensive patterns

Strategy: try-catch

Try / catch

try {
    return query.getResultList();
} catch ( IllegalStateException e ) {
    if ( e.getMessage() != null && e.getMessage().contains("selection indexes size mismatch") ) {
        // order by composite components explicitly instead of the tuple as a whole
        return em.createQuery(expandCompositeOrderBy(hql), type).getResultList();
    }
    throw e;
}

Prevention

When it happens

Trigger: ORDER BY a composite expression (embedded id, @EmbeddedId, composite fk, tuple from a derived select) in a full-join query on an emulating dialect, where translation replaced the SqlTuple (e.g. tuple re-wrapping or expression substitution during emulation branch creation) so lengths diverge.

Common situations: Sorting by a whole embedded/composite value of the full-joined entity on MySQL/MariaDB; queries that worked on earlier 6.x versions regressing after an upgrade to 7.x emulation changes.

Related errors


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