hibernate/hibernate-orm · error · TransactionRequiredException

No active transaction

Error message

No active transaction

What it means

Error "No active transaction" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java:2604

	@Override
	public void detach(@Nonnull Object entity) {
		checkOpen();
		try {
			evict( entity );
		}
		catch (RuntimeException e) {
			throw getExceptionConverter().convert( e );
		}
	}

	@Override
	@Nonnull
	public LockModeType getLockMode(@Nonnull Object entity) {
		checkOpen();

		if ( !isTransactionInProgress() ) {
			throw new TransactionRequiredException( "No active transaction" );
		}

		//noinspection ConstantValue
		if ( entity == null ) {
			throw new IllegalArgumentException( "Entity may not be null" );
		}
		if ( !contains( entity ) ) {
			// convert() calls markForRollbackOnly()
			convertIfJpaBootstrap(
					new UnmanagedObjectException( "Given entity is not associated with the persistence context" ),
					null
			);
		}

		return LockModeTypeHelper.getLockModeType( getCurrentLockMode( entity ) );

	}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Begin a transaction (session.beginTransaction() or @Transactional) before calling the operation that requires one.
  2. Check session.getTransaction().isActive() and start the transaction if needed.

When it happens

Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java:2604 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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