/** * INTERNAL: * Return the value to be stored in the object's attribute. * This value is determined by the query. * In this case, wrap the query in a ValueHolder for later invocation. */ public Object valueFromQuery(ReadQuery query, AbstractRecord row, Object sourceObject, AbstractSession session) { return new QueryBasedValueHolder(query, sourceObject, row, session); }
protected Object instantiate() throws DatabaseException { return instantiate(getSession()); }
/** * Reset all the fields that are not needed after instantiation. */ protected void resetFields() { super.resetFields(); this.mapping = null; this.originalQuery = null; }
/** * Releases a wrapped valueholder privately owned by a particular unit of * work. * <p> * When unit of work clones are built directly from rows no object in the * shared cache points to this valueholder, so it can store the unit of work * as its session. However once that UnitOfWork commits and the valueholder * is merged into the shared cache, the session needs to be reset to the * root session, ie. the server session. */ @Override public void releaseWrappedValueHolder(AbstractSession targetSession) { AbstractSession session = getSession(); if ((session != null) && session.isUnitOfWork()) { setSession(targetSession); } }
/** * Clone the original attribute value. */ public Object buildCloneFor(Object originalAttributeValue) { Integer refreshCascade = null; if (wrappedValueHolder instanceof QueryBasedValueHolder){ refreshCascade = ((QueryBasedValueHolder)getWrappedValueHolder()).getRefreshCascadePolicy(); } Object clone = this.mapping.buildCloneForPartObject(originalAttributeValue, null, null, this.relationshipSourceObject, getUnitOfWork(), refreshCascade, true, true); // Bug 414801 if (wrappedValueHolder.isInstantiated() && refreshCascade != null) { ((QueryBasedValueHolder)getWrappedValueHolder()).setRefreshCascadePolicy(null); } return clone; }
if ((getQuery() == null) || !getQuery().isObjectLevelReadQuery()) { return false; ObjectLevelReadQuery query = (ObjectLevelReadQuery) getQuery(); return query.isLockQuery(getSession());
protected Object instantiate() throws DatabaseException { return instantiate(this.session); }
/** * INTERNAL: * set the source object into QueryBasedValueHolder. * Used only by transparent indirection. */ public void setSourceObject(Object sourceObject, Object attributeValue) { if (attributeValue instanceof QueryBasedValueHolder) { ((QueryBasedValueHolder)attributeValue).setSourceObject(sourceObject); } }
/** * Instantiate the object by executing the query on the session. */ protected Object instantiate(AbstractSession session) throws DatabaseException { if (session == null) { throw ValidationException.instantiatingValueholderWithNullSession(); } if (this.query.isObjectBuildingQuery() && ((ObjectBuildingQuery)this.query).shouldRefreshIdentityMapResult()){ this.refreshCascade = ((ObjectBuildingQuery)this.query).getCascadePolicy(); } Object result = session.executeQuery(getQuery(), getRow()); // Bug 489898 - ensure that the query's session is dereferenced, post-execution getQuery().setSession(null); return result; }
/** * Releases a wrapped valueholder privately owned by a particular unit of * work. * <p> * When unit of work clones are built directly from rows no object in the * shared cache points to this valueholder, so it can store the unit of work * as its session. However once that UnitOfWork commits and the valueholder * is merged into the shared cache, the session needs to be reset to the * root session, ie. the server session. */ @Override public void releaseWrappedValueHolder(AbstractSession targetSession) { AbstractSession session = getSession(); if ((session != null) && session.isUnitOfWork()) { setSession(targetSession); } }
/** * Clone the original attribute value. */ public Object buildCloneFor(Object originalAttributeValue) { Integer refreshCascade = null; if (wrappedValueHolder instanceof QueryBasedValueHolder){ refreshCascade = ((QueryBasedValueHolder)getWrappedValueHolder()).getRefreshCascadePolicy(); } Object clone = this.mapping.buildCloneForPartObject(originalAttributeValue, null, null, this.relationshipSourceObject, getUnitOfWork(), refreshCascade, true, true); // Bug 414801 if (wrappedValueHolder.isInstantiated() && refreshCascade != null) { ((QueryBasedValueHolder)getWrappedValueHolder()).setRefreshCascadePolicy(null); } return clone; }
protected Object instantiate() throws DatabaseException { return instantiate(this.session); }
/** * INTERNAL: * set the source object into QueryBasedValueHolder. * Used only by transparent indirection. */ public void setSourceObject(Object sourceObject, Object attributeValue) { if (attributeValue instanceof QueryBasedValueHolder) { ((QueryBasedValueHolder)attributeValue).setSourceObject(sourceObject); } }
/** * INTERNAL: * Return the value to be stored in the object's attribute. * This value is determined by the query. * In this case, wrap the query in a ValueHolder for later invocation. */ public Object valueFromQuery(ReadQuery query, AbstractRecord row, AbstractSession session) { return new QueryBasedValueHolder(query, row, session); }
if (getQuery() instanceof ReadAllQuery) { if (!org.eclipse.persistence.internal.helper.CubaUtil.isSoftDeletion()) { ReadQuery query = (ReadQuery) getQuery().clone(); query.setIsPrepared(false); return session.executeQuery(query, getRow()); return session.executeQuery(getQuery(), getRow()); } else { boolean softDeletionByMapping = false; DatabaseMapping databaseMapping = getQuery().getSourceMapping(); if (databaseMapping != null && databaseMapping.isOneToOneMapping()) { OneToOneMapping oneToOneMapping = (OneToOneMapping) databaseMapping; ReadQuery query = (ReadQuery) getQuery().clone(); query.setIsPrepared(false); return session.executeQuery(query, getRow()); } else { Boolean prevSoftDeletion = org.eclipse.persistence.internal.helper.CubaUtil.setSoftDeletion(false); try { ReadQuery query = (ReadQuery) getQuery().clone(); query.setIsPrepared(false); return session.executeQuery(query, getRow()); } finally { org.eclipse.persistence.internal.helper.CubaUtil.setSoftDeletion(prevSoftDeletion);
/** * Releases a wrapped valueholder privately owned by a particular unit of * work. * <p> * When unit of work clones are built directly from rows no object in the * shared cache points to this valueholder, so it can store the unit of work * as its session. However once that UnitOfWork commits and the valueholder * is merged into the shared cache, the session needs to be reset to the * root session, ie. the server session. */ public void releaseWrappedValueHolder() { AbstractSession session = getSession(); if ((session != null) && session.isUnitOfWork()) { setSession(session.getRootSession(query)); } }
@Override protected Object instantiate() throws DatabaseException { if (this.session == null){ throw ValidationException.instantiatingValueholderWithNullSession(); } //no need for original or cachekey here as the relationship must be cacheable and present in // wrapped valueholder or the ProtectedValueHolder would not have been created. Integer refreshCascade = null; if (wrappedValueHolder instanceof QueryBasedValueHolder){ refreshCascade = ((QueryBasedValueHolder)getWrappedValueHolder()).getRefreshCascadePolicy(); } Object clone = mapping.buildCloneForPartObject(this.wrappedValueHolder.getValue(),null, null, null, this.session, refreshCascade, true, true); // Bug 414801 if (wrappedValueHolder.isInstantiated() && refreshCascade != null) { ((QueryBasedValueHolder)getWrappedValueHolder()).setRefreshCascadePolicy(null); } return clone; }
/** * Triggers UnitOfWork valueholders directly without triggering the wrapped * valueholder (this). * <p> * When in transaction and/or for pessimistic locking the * UnitOfWorkValueHolder needs to be triggered directly without triggering * the wrapped valueholder. However only the wrapped valueholder knows how * to trigger the indirection, i.e. it may be a batchValueHolder, and it * stores all the info like the row and the query. Note: This method is not * thread-safe. It must be used in a synchronized manner */ public Object instantiateForUnitOfWorkValueHolder(UnitOfWorkValueHolder unitOfWorkValueHolder) { return instantiate(unitOfWorkValueHolder.getUnitOfWork()); }
/** * Reset all the fields that are not needed after instantiation. */ protected void resetFields() { super.resetFields(); this.mapping = null; this.originalQuery = null; }