hibernate/hibernate-orm · error · MappingException
@ManyToMany or @ElementCollection defining filter or where w
Error message
@ManyToMany or @ElementCollection defining filter or where without join fetching not valid within collection using join fetching[<role>]
What it means
Error "@ManyToMany or @ElementCollection defining filter or where without join fetching not valid within collection using join fetching[<role>]" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java:2705
return null;
}
}
private static String extractHqlOrderBy(OrderBy jpaOrderBy) {
return jpaOrderBy != null
// Null not possible. In case of empty expression, apply default ordering.
? jpaOrderBy.value()
// @OrderBy not found.
: null;
}
private static void checkFilterConditions(Collection collection) {
//for now it can't happen, but sometime soon...
if ( ( !collection.getFilters().isEmpty() || isNotBlank( collection.getWhere() ) )
&& collection.getFetchStyle() == FetchStyle.JOIN
&& !( collection.getElement() instanceof SimpleValue ) //SimpleValue (CollectionOfElements) are always SELECT but it does not matter
&& 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 '"View on GitHub (pinned to fad1729dce)
Solutions
- Remove the filter/where clause or change the fetching strategy so join fetching is not combined with filter/where on this collection.
When it happens
Trigger: A @Filter/@FilterJoinTable usage references an undefined filter or has no usable condition.
Common situations: @Filter used without a matching @FilterDef, a misspelled filter name, or neither the usage nor the FilterDef supplying a default condition.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/30c034fff7322c95.
Report an issue: GitHub.