/** * INTERNAL: * Extract the correct query result from the transporter. */ public Object extractRemoteResult(Transporter transporter) { return ((RemoteSession)getSession()).getObjectCorrespondingTo(transporter.getObject(), transporter.getObjectDescriptors(), new IdentityHashMap(), this); }
/** * INTERNAL: * Extract the correct query result from the transporter. */ public Object extractRemoteResult(Transporter transporter) { return ((DistributedSession)getSession()).getObjectCorrespondingTo(transporter.getObject(), transporter.getObjectDescriptors(), new IdentityHashMap(), this); }
/** * INTERNAL: * Extract the correct query result from the transporter. */ public Object extractRemoteResult(Transporter transporter) { return ((DistributedSession)getSession()).getObjectCorrespondingTo(transporter.getObject(), transporter.getObjectDescriptors(), new IdentityHashMap(), this); }
/** * INTERNAL: * Select one object of any concrete subclass. */ protected Object selectOneObject(ReadObjectQuery query) throws DescriptorException { ReadObjectQuery concreteQuery = (ReadObjectQuery)prepareQuery(query); return query.getSession().executeQuery(concreteQuery, concreteQuery.getTranslationRow()); }
/** * INTERNAL: * Select one object of any concrete subclass. */ protected Object selectOneObject(ReadObjectQuery query) throws DescriptorException { ReadObjectQuery concreteQuery = (ReadObjectQuery)prepareQuery(query); return query.getSession().executeQuery(concreteQuery, concreteQuery.getTranslationRow()); }
/** * INTERNAL: * <P> This method is called by the object builder when building an original. * It will cause the original to be cached in the query results if the query * is set to do so. */ public void cacheResult(Object unwrappedOriginal) { Object cachableObject = unwrappedOriginal; if (shouldUseWrapperPolicy()){ cachableObject = getSession().wrapObject(unwrappedOriginal); } setTemporaryCachedQueryResults(cachableObject); }
/** * INTERNAL: * Assign values from objectRow to the object through the mapping. */ protected void assignReturnValueToMapping(Object object, ReadObjectQuery query, AbstractRecord row, DatabaseField field, DatabaseMapping mapping, Collection handledMappings) { if ((handledMappings != null) && handledMappings.contains(mapping)) { return; } if (mapping.isDirectToFieldMapping()) { mapping.readFromRowIntoObject(row, null, object, query, query.getSession()); } else if (mapping.isAggregateObjectMapping()) { ((AggregateObjectMapping)mapping).readFromReturnRowIntoObject(row, object, query, handledMappings); } else if (mapping.isTransformationMapping()) { ((AbstractTransformationMapping)mapping).readFromReturnRowIntoObject(row, object, query, handledMappings); } else { query.getSession().log(SessionLog.FINEST, SessionLog.QUERY, "field_for_unsupported_mapping_returned", field, this.descriptor); } }
/** * INTERNAL: * Extracts value from return row and set the attribute to the value in the object. * Return row is merged into object after execution of insert or update call * accordiing to ReturningPolicy. */ public Object readFromReturnRowIntoObject(AbstractRecord row, Object object, ReadObjectQuery query, Collection handledMappings) throws DatabaseException { AbstractRecord transformationRow = new DatabaseRecord(getFields().size()); for (int i = 0; i < getFields().size(); i++) { DatabaseField field = getFields().elementAt(i); Object value; if (row.containsKey(field)) { value = row.get(field); } else { value = valueFromObject(object, field, query.getSession()); } transformationRow.add(field, value); } Object attributeValue = readFromRowIntoObject(transformationRow, null, object, query, query.getSession()); if (handledMappings != null) { handledMappings.add(this); } return attributeValue; }
/** * INTERNAL: * Select one object of any concrete subclass. */ protected Object selectOneObject(ReadObjectQuery query) throws DescriptorException { ReadObjectQuery concreteQuery = (ReadObjectQuery) query.clone(); Class javaClass = descriptor.getJavaClass(); concreteQuery.setReferenceClass(javaClass); concreteQuery.setDescriptor(descriptor); return query.getSession().executeQuery(concreteQuery, concreteQuery.getTranslationRow()); }
/** * INTERNAL: * Prepare the receiver for execution in a session. */ protected void prePrepare() throws QueryException { super.prePrepare(); //Bug#3947714 In case getSelectionObject() is proxy if (getSelectionObject() != null && getSession().getProject().hasProxyIndirection()) { setSelectionObject(ProxyIndirectionPolicy.getValueFromProxy(getSelectionObject())); } }
/** * INTERNAL: * Select one object of any concrete subclass. */ @Override protected Object selectOneObject(ReadObjectQuery query) throws DescriptorException { // If we came from a source mapping the execute the selection query // we prepared from it. if (selectionQueriesForAllObjects.containsKey(query.getSourceMapping())) { return query.getExecutionSession().executeQuery(selectionQueriesForAllObjects.get(query.getSourceMapping()), query.getTranslationRow()); } else { // Assuming we're doing a find by primary key ... // We have to update the translation row to be to the correct field. AbstractRecord translationRow = (AbstractRecord) query.getTranslationRow().clone(); Vector allFields = new Vector(); for (DatabaseField field : (Vector<DatabaseField>) translationRow.getFields()) { // Remove the table and let the descriptor figure it out. allFields.add(new DatabaseField(field.getName())); } translationRow.getFields().clear(); translationRow.getFields().addAll(allFields); return query.getSession().executeQuery(getDescriptor().getQueryManager().getReadObjectQuery(), translationRow); } } }
/** * INTERNAL: * Prepare the receiver for execution in a session. */ protected void prePrepare() throws QueryException { super.prePrepare(); //Bug#3947714 In case getSelectionObject() is proxy if (getSelectionObject() != null && getSession().getProject().hasProxyIndirection()) { setSelectionObject(ProxyIndirectionPolicy.getValueFromProxy(getSelectionObject())); } }
/** * INTERNAL: * Prepare the receiver for execution in a session. */ protected void prePrepare() throws QueryException { super.prePrepare(); //Bug#3947714 In case getSelectionObject() is proxy if (getSelectionObject() != null && getSession().getProject().hasProxyIndirection()) { setSelectionObject(ProxyIndirectionPolicy.getValueFromProxy(getSelectionObject())); } }
/** * INTERNAL: * Prepare the receiver for execution in a session. */ public void prepareForExecution() throws QueryException { super.prepareForExecution(); // For bug 2989998 the translation row now sometimes set earlier in prepare. if (shouldPrepare()) { if (getSelectionKey() != null) { // Row must come from the key. setTranslationRow(this.descriptor.getObjectBuilder().buildRowFromPrimaryKeyValues(getSelectionKey(), getSession())); } else if (getSelectionObject() != null) { // The expression is set in the prepare as params. setTranslationRow(this.descriptor.getObjectBuilder().buildRowForTranslation(getSelectionObject(), getSession())); } } }
protected Object remoteExecute() { // Do a cache lookup. checkDescriptor(session); // As the selection object is transient, compute the key. if (getSelectionObject() != null) { // Must be checked separately as the expression and row is not yet set. setSelectionKey(getDescriptor().getObjectBuilder().extractPrimaryKeyFromObject(getSelectionObject(), session)); } Object cacheHit = checkEarlyReturn(getSession(), getTranslationRow()); if ((cacheHit != null) || shouldCheckCacheOnly()) { return cacheHit; } return super.remoteExecute(); }
protected Object remoteExecute() { // Do a cache lookup. checkDescriptor(session); // As the selection object is transient, compute the key. if (getSelectionObject() != null) { // Must be checked separately as the expression and row is not yet set. setSelectionId(getDescriptor().getObjectBuilder().extractPrimaryKeyFromObject(getSelectionObject(), session)); } Object cacheHit = checkEarlyReturn(getSession(), getTranslationRow()); if ((cacheHit != null) || shouldCheckCacheOnly()) { if (cacheHit == InvalidObject.instance) { return null; } return cacheHit; } return super.remoteExecute(); }
protected Object remoteExecute() { // Do a cache lookup. checkDescriptor(session); // As the selection object is transient, compute the key. if (getSelectionObject() != null) { // Must be checked separately as the expression and row is not yet set. setSelectionId(getDescriptor().getObjectBuilder().extractPrimaryKeyFromObject(getSelectionObject(), session)); } Object cacheHit = checkEarlyReturn(getSession(), getTranslationRow()); if ((cacheHit != null) || shouldCheckCacheOnly()) { if (cacheHit == InvalidObject.instance) { return null; } return cacheHit; } return super.remoteExecute(); }
/** * INTERNAL: * Select one row of any concrete subclass, * This must use two selects, the first retrieves the type field only. */ protected AbstractRecord selectOneRowUsingDefaultMultipleTableSubclassRead(ReadObjectQuery query) throws DatabaseException, QueryException { // Get the row for the given class indicator field // The indicator select is prepared in the original query, so can just be executed. AbstractRecord typeRow = ((ExpressionQueryMechanism)query.getQueryMechanism()).selectOneRowFromTable(); if (typeRow == null) { return null; } Class concreteClass = classFromRow(typeRow, query.getSession()); ClassDescriptor concreteDescriptor = getDescriptor(concreteClass); if (concreteDescriptor == null) { throw QueryException.noDescriptorForClassFromInheritancePolicy(query, concreteClass); } ReadObjectQuery concreteQuery = (ReadObjectQuery)query.clone(); concreteQuery.setReferenceClass(concreteClass); concreteQuery.setDescriptor(concreteDescriptor); AbstractRecord resultRow = ((ExpressionQueryMechanism)concreteQuery.getQueryMechanism()).selectOneRowFromConcreteTable(); return resultRow; }
/** * INTERNAL: * Select one row of any concrete subclass, * This must use two selects, the first retrieves the type field only. */ protected AbstractRecord selectOneRowUsingDefaultMultipleTableSubclassRead(ReadObjectQuery query) throws DatabaseException, QueryException { // Get the row for the given class indicator field // The indicator select is prepared in the original query, so can just be executed. AbstractRecord typeRow = ((ExpressionQueryMechanism)query.getQueryMechanism()).selectOneRowFromTable(); if (typeRow == null) { return null; } Class concreteClass = classFromRow(typeRow, query.getSession()); ClassDescriptor concreteDescriptor = getDescriptor(concreteClass); if (concreteDescriptor == null) { throw QueryException.noDescriptorForClassFromInheritancePolicy(query, concreteClass); } ReadObjectQuery concreteQuery = (ReadObjectQuery)query.clone(); concreteQuery.setReferenceClass(concreteClass); concreteQuery.setDescriptor(concreteDescriptor); AbstractRecord resultRow = ((ExpressionQueryMechanism)concreteQuery.getQueryMechanism()).selectOneRowFromConcreteTable(); return resultRow; }
/** * INTERNAL: * Select one row of any concrete subclass, * This must use two selects, the first retrieves the type field only. */ protected AbstractRecord selectOneRowUsingDefaultMultipleTableSubclassRead(ReadObjectQuery query) throws DatabaseException, QueryException { // Get the row for the given class indicator field // The indicator select is prepared in the original query, so can just be executed. AbstractRecord typeRow = ((ExpressionQueryMechanism)query.getQueryMechanism()).selectOneRowFromTable(); if (typeRow == null) { return null; } Class concreteClass = classFromRow(typeRow, query.getSession()); ClassDescriptor concreteDescriptor = getDescriptor(concreteClass); if (concreteDescriptor == null) { throw QueryException.noDescriptorForClassFromInheritancePolicy(query, concreteClass); } ReadObjectQuery concreteQuery = (ReadObjectQuery)query.clone(); concreteQuery.setReferenceClass(concreteClass); concreteQuery.setDescriptor(concreteDescriptor); AbstractRecord resultRow = ((ExpressionQueryMechanism)concreteQuery.getQueryMechanism()).selectOneRowFromConcreteTable(); return resultRow; }