hibernate/hibernate-orm · error · HibernateException

Unable to copy stream content

Error message

Unable to copy stream content

What it means

Error "Unable to copy stream content" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java:2020

	/**
	 * A {@link LobMergeStrategy} based on transferring contents using streams.
	 */
	@SuppressWarnings("unused")
	protected static final LobMergeStrategy STREAM_XFER_LOB_MERGE_STRATEGY = new LobMergeStrategy() {
		@Override
		public Blob mergeBlob(Blob original, Blob target, SharedSessionContractImplementor session) {
			if ( original != target ) {
				try {
					// the BLOB just read during the load phase of merge
					final var connectedStream = target.setBinaryStream( 1L );
					// the BLOB from the detached state
					final var detachedStream = original.getBinaryStream();
					detachedStream.transferTo( connectedStream );
					return target;
				}
				catch (IOException e ) {
					throw new HibernateException( "Unable to copy stream content", e );
				}
				catch (SQLException e ) {
					throw session.getFactory().getJdbcServices().getSqlExceptionHelper()
							.convert( e, "unable to merge BLOB data" );
				}
			}
			else {
				return NEW_LOCATOR_LOB_MERGE_STRATEGY.mergeBlob( original, target, session );
			}
		}

		@Override
		public Clob mergeClob(Clob original, Clob target, SharedSessionContractImplementor session) {
			if ( original != target ) {
				try {
					// the CLOB just read during the load phase of merge
					final var connectedStream = target.setAsciiStream( 1L );
					// the CLOB from the detached state

View on GitHub (pinned to fad1729dce)

Solutions

  1. Check the underlying IOException cause (stream closed early, network failure) and retry with a valid readable stream.

Example fix

Check the underlying IOException cause (stream closed early, network failure) and retry with a valid readable stream.

When it happens

Trigger: A dialect-specific function or stream operation is used that the current database dialect does not support.

Common situations: Calling timestampadd()/timestampdiff() on dialects lacking support, or LOB stream handling hitting IO failures.


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