hibernate/hibernate-orm · error · AnnotationException
Join column '<columnName>' on collection property '<role>' m
Error message
Join column '<columnName>' on collection property '<role>' must be defined with the same insertable and updatable attributes
What it means
Error "Join column '<columnName>' on collection property '<role>' must be defined with the same insertable and updatable attributes" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java:2722
&& collection.getElement().getFetchStyle() != FetchStyle.JOIN ) {
throw new MappingException(
"@ManyToMany or @ElementCollection defining filter or where without join fetching "
+ "not valid within collection using join fetching[" + collection.getRole() + "]"
);
}
}
private static void checkConsistentColumnMutability(Collection collection) {
checkConsistentColumnMutability( collection.getRole(), collection.getKey() );
checkConsistentColumnMutability( collection.getRole(), collection.getElement() );
}
private static void checkConsistentColumnMutability(String collectionRole, Value value) {
Boolean readOnly = null;
for ( int i = 0; i < value.getColumnSpan(); i++ ) {
final boolean insertable = value.isColumnInsertable( i );
if ( insertable != value.isColumnUpdateable( i ) ) {
throw new AnnotationException(
"Join column '" + value.getColumns().get( i ).getName() + "' on collection property '"
+ collectionRole + "' must be defined with the same insertable and updatable attributes"
);
}
if ( readOnly == null ) {
readOnly = insertable;
}
else if ( readOnly != insertable && !value.getColumns().get( i ).isFormula() ) {
// We also assert that all join columns have the same mutability (except formulas)
throw new AnnotationException(
"All join columns on collection '" + collectionRole + "' should have" +
" the same insertable and updatable setting"
);
}
}
}
private void bindCollectionSecondPass(PersistentClass targetEntity, AnnotatedJoinColumns joinColumns) {View on GitHub (pinned to fad1729dce)
Solutions
- Set the same insertable and updatable values on every @JoinColumn of the collection.
When it happens
Trigger: A '@JoinColumn' / 'referencedColumnName' does not line up with the columns mapped by the target entity.
Common situations: Composite foreign keys, associations to entities with secondary tables, or reordered/duplicated referencedColumnName values across multiple @JoinColumn declarations.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/b208698870cb7dee.
Report an issue: GitHub.