hibernate/hibernate-orm · error · PersistentObjectException

Object was an uninitialized proxy for {entityName}

Error message

Object was an uninitialized proxy for {entityName}

What it means

Error "Object was an uninitialized proxy for {entityName}" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/engine/internal/ProxyUtil.java:32

import static org.hibernate.engine.internal.ManagedTypeHelper.isPersistentAttributeInterceptable;
import static org.hibernate.proxy.HibernateProxy.extractLazyInitializer;

/**
 * @author Gavin King
 * @since 7.2
 */
public class ProxyUtil {

	/**
	 * Get the entity instance underlying the given proxy, throwing
	 * an exception if the proxy is uninitialized. If the given
	 * object is not a proxy, simply return the argument.
	 */
	public static Object assertInitialized(Object maybeProxy) {
		final var lazyInitializer = extractLazyInitializer( maybeProxy );
		if ( lazyInitializer != null ) {
			if ( lazyInitializer.isUninitialized() ) {
				throw new PersistentObjectException( "Object was an uninitialized proxy for "
													+ lazyInitializer.getEntityName() );
			}
			//unwrap the object and return
			return lazyInitializer.getImplementation();
		}
		else {
			return maybeProxy;
		}
	}

	/**
	 * Get the entity instance underlying the given proxy, forcing
	 * initialization if the proxy is uninitialized. If the given
	 * object is not a proxy, simply return the argument.
	 * @throws DetachedObjectException if the given proxy does not
	 *         belong to the given session
	 */
	public static Object forceInitialize(Object maybeProxy, SharedSessionContractImplementor session) {

View on GitHub (pinned to fad1729dce)

Solutions

  1. Initialize the proxy (Hibernate.initialize) before the operation that needs the real instance
  2. Fetch the entity eagerly or within an open session so no uninitialized proxy remains

When it happens

Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/engine/internal/ProxyUtil.java:32 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/a3569bc54cc84e82. Report an issue: GitHub.