/** * Return the object. */ @Override public Object getValue() { boolean instantiated = this.isInstantiated; if (!instantiated) { synchronized (this) { instantiated = this.isInstantiated; if (!instantiated) { // The value must be set directly because the setValue can also cause instantiation under UOW. privilegedSetValue(instantiate()); this.isInstantiated = true; postInstantiate(); resetFields(); } } } return value; }
/** * Return the object. */ public Object getValue() { if (!this.isInstantiated) { synchronized (this) { if (!this.isInstantiated) { // cuba begin: We have added the following code to prevent fetch of lazy fields // from database when transaction is already finished if (session instanceof UnitOfWorkImpl) { if (((UnitOfWorkImpl) session).getLifecycle() >= UnitOfWorkImpl.Death) { throwUnfetchedAttributeException(); } } // cuba end // The value must be set directly because the setValue can also cause instantiation under UOW. privilegedSetValue(instantiate()); // Cycles can somehow recurse into this twice... if (this.isInstantiated) { return value; } this.isInstantiated = true; postInstantiate(); resetFields(); } } } return value; }