hibernate/hibernate-orm · error · QueryException

Unsupported model part container: {modelPartContainer}

Error message

Unsupported model part container: {modelPartContainer}

What it means

The HANA json_table emulation adds id columns to identify rows. addIdColumns accepts only EntityValuedModelPart, PluralAttributeMapping, and EmbeddableValuedModelPart containers. Any other ModelPartContainer type reaches the else branch and throws this QueryException.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/dialect/function/json/HANAJsonTableFunction.java:341

								)
						);
					}
					return new SqlTuple( expressions, null );
				}
			}

			private void addIdColumns(ModelPartContainer modelPartContainer, List<ColumnInfo> idColumns) {
				if ( modelPartContainer instanceof EntityValuedModelPart entityValuedModelPart ) {
					addIdColumns( entityValuedModelPart.getEntityMappingType(), idColumns );
				}
				else if ( modelPartContainer instanceof PluralAttributeMapping pluralAttributeMapping ) {
					addIdColumns( pluralAttributeMapping, idColumns );
				}
				else if ( modelPartContainer instanceof EmbeddableValuedModelPart embeddableModelPart ) {
					addIdColumns( embeddableModelPart, idColumns );
				}
				else {
					throw new QueryException( "Unsupported model part container: " + modelPartContainer );
				}
			}

			private void addIdColumns(EmbeddableValuedModelPart embeddableModelPart, List<ColumnInfo> idColumns) {
				if ( embeddableModelPart instanceof EmbeddedCollectionPart collectionPart ) {
					addIdColumns( collectionPart.getCollectionAttribute(), idColumns );
				}
				else {
					addIdColumns( embeddableModelPart.asAttributeMapping().getDeclaringType(), idColumns );
				}
			}

			private void addIdColumns(PluralAttributeMapping pluralAttributeMapping, List<ColumnInfo> idColumns) {
				final var ddlTypeRegistry = pluralAttributeMapping.getCollectionDescriptor()
						.getFactory()
						.getTypeConfiguration()
						.getDdlTypeRegistry();
				addIdColumns( pluralAttributeMapping.getKeyDescriptor().getKeyPart(), ddlTypeRegistry, idColumns );

View on GitHub (pinned to fad1729dce)

Solutions

  1. Test the same query on a dialect with native json_table (PostgreSQL, Oracle) to confirm the mapping itself is valid.
  2. Rewrite the statement as a native HANA SQL query for this table function use.
  3. Simplify the involved mapping, for example replace the unusual structure with a plain embeddable or element collection.
  4. Report the mapping to the Hibernate issue tracker with a reproducing test; this branch indicates an emulation gap.
Defensive patterns

Strategy: try-catch

Try / catch

try {
    return session.createQuery(hql).getResultList();
} catch (org.hibernate.QueryException e) {
    if (e.getMessage() != null && e.getMessage().contains("Unsupported model part container")) {
        // Emulation gap: fall back to native HANA SQL for this statement.
        return session.createNativeQuery(nativeSql, Tuple.class).getResultList();
    }
    throw e;
}

Prevention

When it happens

Trigger: Running a json_table query on HANA when the associated mapping exposes a model part container outside the three handled types, for example an unusual or custom mapping structure reached through the table function column mapping.

Common situations: Custom or rarely used mapping combinations (for example special collection parts or generated mappings) in an entity used with json_table on HANA. Upgrading Hibernate and hitting a mapping shape the HANA emulation never covered.

Related errors


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