hibernate/hibernate-orm · error · JDBCConnectionException

Could not create connection

Error message

Could not create connection

What it means

To emulate a full join as a UNION, Hibernate must build nullness predicates ('this side was matched') from the columns of the joined side, so it reduces the joined ModelPart to something column-backed: an identifier mapping, an entity identifier, a plural-attribute key, or any ValuedModelPart. This error means the joined part is of a kind that exposes no selectable columns, so the null-check branch of the emulation cannot be rendered. It signals an exotic or unsupported mapping rather than a malformed query.

Source

Thrown at hibernate-agroal/src/main/java/org/hibernate/agroal/internal/AgroalConnectionProvider.java:204

					hasCatalog( connection ),
					getSchema( connection ),
					getCatalog( connection ),
					Boolean.toString( connectionConfig.autoCommit() ),
					connectionConfig.jdbcTransactionIsolation() != null
						&& connectionConfig.jdbcTransactionIsolation().isDefined()
							? toIsolationNiceName( connectionConfig.jdbcTransactionIsolation().level() )
							: toIsolationNiceName( getIsolation( connection ) ),
					poolConfig.minSize(),
					poolConfig.maxSize(),
					getFetchSize( connection )
			);
			if ( !connection.getAutoCommit() ) {
				connection.rollback();
			}
			return info;
		}
		catch (SQLException e) {
			throw new JDBCConnectionException( "Could not create connection", e );
		}
	}

	@Override
	public boolean isUnwrappableAs(@Nonnull Class<?> unwrapType) {
		return unwrapType.isAssignableFrom( AgroalConnectionProvider.class )
			|| unwrapType.isAssignableFrom( AgroalDataSource.class );
	}

	@Override
	@SuppressWarnings( "unchecked" )
	public <T> T unwrap(@Nonnull Class<T> unwrapType) {
		if ( unwrapType.isAssignableFrom( AgroalConnectionProvider.class ) ) {
			return (T) this;
		}
		else if ( unwrapType.isAssignableFrom( AgroalDataSource.class ) ) {
			return (T) agroalDataSource;
		}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Full join a regular entity association or plural attribute that is column-backed instead of the exotic path.
  2. Restructure the query as an explicit union of left join and right join so no emulation nullness predicate is needed.
  3. Upgrade to the latest Hibernate 7.x - model-part coverage of this helper may have been extended.
  4. If it persists, report to Hibernate (HHH) with the mapping that produced the part name in the message.
Defensive patterns

Strategy: try-catch

Try / catch

try {
    return em.createQuery(hql, type).getResultList();
} catch ( UnsupportedOperationException e ) {
    if ( e.getMessage() != null && e.getMessage().startsWith("Full join emulation requires a table group") ) {
        // fall back to explicit union of left join + right join
        return runManualFullJoin( hql );
    }
    throw e;
}

Prevention

When it happens

Trigger: A full join whose joined model part cannot be reduced to a ValuedModelPart in getValuedModelPart(...): not a mapping type with identifier, not an EntityValuedModelPart, not a PluralAttributeMapping, and not a ValuedModelPart - e.g. certain virtual/container model parts produced by custom persister, custom mapping types, or unusual embeddable/id mappings, on the full-join-emulating dialects.

Common situations: Custom MappingType/Persister implementations or dialect extensions after a Hibernate upgrade changed the model-part hierarchy; joining an association whose target uses a non-standard mapped type; experimental full join support combined with virtual id embeddings.

Related errors


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