hibernate/hibernate-orm · error · UnsupportedOperationException
Could not create many-to-many foreign-key : %s
Error message
Could not create many-to-many foreign-key : %s
What it means
Error "Could not create many-to-many foreign-key : %s" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ManyToManyCollectionPart.java:654
);
}
if ( fkTargetModelPart instanceof EmbeddableValuedModelPart embeddableValuedModelPart ) {
return MappingModelCreationHelper.buildEmbeddableForeignKeyDescriptor(
propertyPath,
embeddableValuedModelPart,
fkBootDescriptorSource,
findContainingEntityMapping(),
getCollectionDescriptor().getAttributeMapping(),
null,
false,
fkBootDescriptorSource.getColumnInsertability(),
fkBootDescriptorSource.getColumnUpdateability(),
creationProcess
);
}
throw new UnsupportedOperationException(
"Could not create many-to-many foreign-key : " + getNavigableRole().getFullPath()
);
}
private ForeignKeyDescriptor determineForeignKey(
ForeignKeyDescriptor foreignKeyDescriptor,
Value fkBootDescriptorSource,
@Nullable String propertyPath,
MappingModelCreationProcess creationProcess) {
final int selectableCount = foreignKeyDescriptor.getJdbcTypeCount();
final var keyPart = foreignKeyDescriptor.getKeyPart();
for ( int i = 0; i < selectableCount; i++ ) {
final var selectable = keyPart.getSelectable( i );
if ( selectable.isInsertable() != fkBootDescriptorSource.isColumnInsertable( i )
|| selectable.isUpdateable() != fkBootDescriptorSource.isColumnUpdateable( i ) ) {
final var attributeMapping = keyPart.asAttributeMapping();
final var declaringType =
attributeMapping == null ? null : attributeMapping.getDeclaringType();View on GitHub (pinned to fad1729dce)
Solutions
- Check the many-to-many join table mapping: join columns and inverse join columns must reference existing columns of the join table.
- Verify the target entity of the many-to-many is correctly mapped.
When it happens
Trigger: Thrown when constructing the foreign key descriptor for a many-to-many collection fails because the key mappings are inconsistent.
Common situations: See trigger scenarios.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/d0f8d65498e4e010.
Report an issue: GitHub.