{"record":{"id":"a3569bc54cc84e82","repo":"hibernate/hibernate-orm","slug":"object-was-an-uninitialized-proxy-for-entityname","errorCode":null,"errorMessage":"Object was an uninitialized proxy for {entityName}","messagePattern":"Object was an uninitialized proxy for (.+?)","errorType":"exception","errorClass":"PersistentObjectException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/engine/internal/ProxyUtil.java","lineNumber":32,"sourceCode":"import static org.hibernate.engine.internal.ManagedTypeHelper.isPersistentAttributeInterceptable;\nimport static org.hibernate.proxy.HibernateProxy.extractLazyInitializer;\n\n/**\n * @author Gavin King\n * @since 7.2\n */\npublic class ProxyUtil {\n\n\t/**\n\t * Get the entity instance underlying the given proxy, throwing\n\t * an exception if the proxy is uninitialized. If the given\n\t * object is not a proxy, simply return the argument.\n\t */\n\tpublic static Object assertInitialized(Object maybeProxy) {\n\t\tfinal var lazyInitializer = extractLazyInitializer( maybeProxy );\n\t\tif ( lazyInitializer != null ) {\n\t\t\tif ( lazyInitializer.isUninitialized() ) {\n\t\t\t\tthrow new PersistentObjectException( \"Object was an uninitialized proxy for \"\n\t\t\t\t\t\t\t\t\t\t\t\t\t+ lazyInitializer.getEntityName() );\n\t\t\t}\n\t\t\t//unwrap the object and return\n\t\t\treturn lazyInitializer.getImplementation();\n\t\t}\n\t\telse {\n\t\t\treturn maybeProxy;\n\t\t}\n\t}\n\n\t/**\n\t * Get the entity instance underlying the given proxy, forcing\n\t * initialization if the proxy is uninitialized. If the given\n\t * object is not a proxy, simply return the argument.\n\t * @throws DetachedObjectException if the given proxy does not\n\t *         belong to the given session\n\t */\n\tpublic static Object forceInitialize(Object maybeProxy, SharedSessionContractImplementor session) {","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/engine/internal/ProxyUtil.java#L14-L50","documentation":"Error \"Object was an uninitialized proxy for {entityName}\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown at hibernate-core/src/main/java/org/hibernate/engine/internal/ProxyUtil.java:32 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Initialize the proxy (Hibernate.initialize) before the operation that needs the real instance","Fetch the entity eagerly or within an open session so no uninitialized proxy remains"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}