@Override public AbstractRecord getRow() { return ((DatabaseValueHolder)this.unitOfWorkValueHolder).getRow(); }
/** * INTERNAL: * Return the original indirection object for a unit of work indirection object. */ @Override public Object getOriginalIndirectionObjectForMerge(Object unitOfWorkIndirectionObject, AbstractSession session) { DatabaseValueHolder holder = (DatabaseValueHolder)getOriginalIndirectionObject(unitOfWorkIndirectionObject, session); if (holder != null && holder.getSession()!= null){ holder.setSession(session); } return holder; }
@Override public String toString() { if (isInstantiated()) { return "{" + getValue() + "}"; } else { return "{" + Helper.getShortClassName(getClass()) + ": " + ToStringLocalization.buildMessage("not_instantiated", (Object[])null) + "}"; } } }
/** * Return the object. */ public Object getValue() { if (!isInstantiated()) { synchronized (this) { if (!isInstantiated()) { // The value must be set directly because the setValue can also cause instantiation under UOW. privilegedSetValue(instantiate()); setInstantiated(); resetFields(); } } } return value; }
/** * 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; }
&& (! ((DatabaseValueHolder) valueHolder).isInstantiated()) && (((DatabaseValueHolder) valueHolder).getSession() == null) && (! ((DatabaseValueHolder) valueHolder).isSerializedRemoteUnitOfWorkValueHolder())) { throw DescriptorException.attemptToRegisterDeadIndirection(original, this.mapping); row = ((DatabaseValueHolder)valueHolder).getRow(); AbstractRecord row = null; if (valueHolder instanceof DatabaseValueHolder) { row = ((DatabaseValueHolder)valueHolder).getRow();
&& (! ((DatabaseValueHolder) valueHolder).isInstantiated()) && (((DatabaseValueHolder) valueHolder).getSession() == null) && (! ((DatabaseValueHolder) valueHolder).isSerializedRemoteUnitOfWorkValueHolder())) { throw DescriptorException.attemptToRegisterDeadIndirection(original, this.mapping); row = ((DatabaseValueHolder)valueHolder).getRow(); container = buildIndirectContainer(newValueHolder); Object cloneCollection = this.mapping.buildCloneForPartObject(attributeValue, original, cacheKey, clone, cloningSession, refreshCascade, false, false); newValueHolder.privilegedSetValue(cloneCollection); newValueHolder.setInstantiated(); row = ((DatabaseValueHolder)valueHolder).getRow();
DatabaseValueHolder wrapped = (DatabaseValueHolder)this.wrappedValueHolder; UnitOfWorkImpl unitOfWork = getUnitOfWork(); if (!wrapped.isEasilyInstantiated()) { if (wrapped.isPessimisticLockingValueHolder()) { if (!unitOfWork.getCommitManager().isActive() && !unitOfWork.wasTransactionBegunPrematurely()) { unitOfWork.beginEarlyTransaction(); return wrapped.instantiateForUnitOfWorkValueHolder(this); if (!((DatabaseValueHolder)this.wrappedValueHolder).isInstantiated()){ Object result = ((DatabaseValueHolder)this.wrappedValueHolder).getValue((UnitOfWorkImpl) this.session); if (result != null){ return result;
/** * INTERNAL: * Answers if this valueholder is easy to instantiate. * @return true if getValue() won't trigger a database read. */ public boolean isEasilyInstantiated() { return this.isInstantiated || ((this.wrappedValueHolder != null) && (!(this.wrappedValueHolder instanceof DatabaseValueHolder) || ((DatabaseValueHolder)this.wrappedValueHolder).isEasilyInstantiated())); }
DatabaseValueHolder wrapped = (DatabaseValueHolder)getWrappedValueHolder(); UnitOfWorkImpl unitOfWork = getUnitOfWork(); if (!wrapped.isEasilyInstantiated()) { if (wrapped.isPessimisticLockingValueHolder()) { if (!unitOfWork.getCommitManager().isActive() && !unitOfWork.wasTransactionBegunPrematurely()) { unitOfWork.beginEarlyTransaction(); return wrapped.instantiateForUnitOfWorkValueHolder(this);
@Override public boolean isPessimisticLockingValueHolder() { return ((DatabaseValueHolder)this.unitOfWorkValueHolder).isPessimisticLockingValueHolder(); }
@Override public Object instantiateForUnitOfWorkValueHolder(UnitOfWorkValueHolder unitOfWorkValueHolder) { return ((DatabaseValueHolder)this.unitOfWorkValueHolder).instantiateForUnitOfWorkValueHolder(unitOfWorkValueHolder); }
/** * INTERNAL: * Returns the attribute value from the reference object. * If the attribute is using indirection the value of the value-holder is returned. * If the value holder is not instantiated then it is instantiated. */ public Object getAttributeValueWithClonedValueHolders(Object object) { Object attributeValue = getAttributeValueFromObject(object); if (attributeValue instanceof DatabaseValueHolder){ return ((DatabaseValueHolder)attributeValue).clone(); } else if (attributeValue instanceof ValueHolder){ return ((ValueHolder)attributeValue).clone(); } return attributeValue; }
@Override public AbstractSession getSession() { return ((DatabaseValueHolder)this.unitOfWorkValueHolder).getSession(); }
/** * INTERNAL: * Answers if this valueholder is easy to instantiate. * @return true if getValue() won't trigger a database read. */ public boolean isEasilyInstantiated() { return isInstantiated(); }
&& (! ((DatabaseValueHolder) valueHolder).isInstantiated()) && (((DatabaseValueHolder) valueHolder).getSession() == null) && (! ((DatabaseValueHolder) valueHolder).isSerializedRemoteUnitOfWorkValueHolder())) { throw DescriptorException.attemptToRegisterDeadIndirection(original, this.mapping); row = ((DatabaseValueHolder)valueHolder).getRow(); AbstractRecord row = null; if (valueHolder instanceof DatabaseValueHolder) { row = ((DatabaseValueHolder)valueHolder).getRow();
&& (! ((DatabaseValueHolder) valueHolder).isInstantiated()) && (((DatabaseValueHolder) valueHolder).getSession() == null) && (! ((DatabaseValueHolder) valueHolder).isSerializedRemoteUnitOfWorkValueHolder())) { throw DescriptorException.attemptToRegisterDeadIndirection(original, this.mapping); row = ((DatabaseValueHolder)valueHolder).getRow(); container = buildIndirectContainer(newValueHolder); Object cloneCollection = this.mapping.buildCloneForPartObject(attributeValue, original, cacheKey, clone, cloningSession, refreshCascade, false, false); newValueHolder.privilegedSetValue(cloneCollection); newValueHolder.setInstantiated(); row = ((DatabaseValueHolder)valueHolder).getRow();
DatabaseValueHolder wrapped = (DatabaseValueHolder)this.wrappedValueHolder; UnitOfWorkImpl unitOfWork = getUnitOfWork(); if (!wrapped.isEasilyInstantiated()) { if (wrapped.isPessimisticLockingValueHolder()) { if (!unitOfWork.getCommitManager().isActive() && !unitOfWork.wasTransactionBegunPrematurely()) { unitOfWork.beginEarlyTransaction(); return wrapped.instantiateForUnitOfWorkValueHolder(this); if (!((DatabaseValueHolder)this.wrappedValueHolder).isInstantiated()){ Object result = ((DatabaseValueHolder)this.wrappedValueHolder).getValue((UnitOfWorkImpl) this.session); if (result != null){ return result;
/** * 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; }
/** * INTERNAL: * Return whether the specified object can be instantiated without database access. */ public boolean objectIsEasilyInstantiated(Object object) { if (object instanceof DatabaseValueHolder) { return ((DatabaseValueHolder)object).isEasilyInstantiated(); } else { return true; } }