hibernate/hibernate-orm · error · UnsupportedOperationException

Operation not supported: %s.remove()

Error message

Operation not supported: %s.remove()

What it means

Error "Operation not supported: %s.remove()" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/event/spi/MergeContext.java:291

	 * @param map keys and values must be non-null
	 * @throws NullPointerException if any key or value is null
	 * @throws IllegalArgumentException if a key in <code>map</code> was already in this MergeContext
	 * but associated value in <code>map</code> is different from the previous value in this MergeContext.
	 * @throws IllegalStateException if internal cross-references are out of sync,
	 */
	public void putAll(@Nonnull Map<?,?> map) {
		for ( var entry : map.entrySet() ) {
			put( entry.getKey(), entry.getValue() );
		}
	}

	/**
	 * The remove operation is not supported.
	 * @param mergeEntity the merge entity.
	 * @throws UnsupportedOperationException if called.
	 */
	public @Nullable Object remove(@Nonnull Object mergeEntity) {
		throw new UnsupportedOperationException(
				String.format( "Operation not supported: %s.remove()", getClass().getName() )
		);
	}

	/**
	 * Returns the number of merge-to-managed entity cross-references in this MergeContext
	 * @return the number of merge-to-managed entity cross-references in this MergeContext
	 */
	public int size() {
		return mergeToManagedEntityXref.size();
	}

	/**
	 * Returns an unmodifiable Set view of managed entities contained in this MergeContext.
	 * @return an unmodifiable Set view of managed entities contained in this MergeContext
	 *
	 * @see Collections#unmodifiableSet(Set)
	 */

View on GitHub (pinned to fad1729dce)

Solutions

  1. Do not call remove() on the merge context entry set iterator; this operation is unsupported by design.

When it happens

Trigger: Thrown when remove() is called on a MergeContext entry set/iterator, which is a read-only view.

Common situations: Typical situations: code iterating the merge map attempting to delete entries; framework-extension code misusing the MergeContext API.


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