protected Object getObjectFromResultSet() throws PersistenceBrokerException
    {
        getRow().clear();
        /**
         * MBAIRD if a proxy is to be used, return a proxy instance and dont
         * perfom a full materialization. NOTE: Potential problem here with
         * multi-mapped table. The itemProxyClass is for the m_cld
         * classdescriptor. The object you are materializing might not be of
         * that type, it could be a subclass. We should get the concrete class
         * type out of the resultset then check the proxy from that.
         * itemProxyClass should NOT be a member variable.
         */

        RowReader rowReader = getQueryObject().getClassDescriptor().getRowReader();
        // in any case we need the PK values of result set row
        // provide m_row with primary key data of current row
        rowReader.readPkValuesFrom(getRsAndStmt(), getRow());

        if (getItemProxyClass() != null)
        {
            // assert: m_row is filled with primary key values from db
            return getProxyFromResultSet();
        }
        else
        {
            // 1.read Identity
            Identity oid = getIdentityFromResultSet();
            Object result;

            // 2. check if Object is in cache. if so return cached version.
            result = getCache().lookup(oid);
            if (result == null)
            {

                // map all field values from the current result set
                rowReader.readObjectArrayFrom(getRsAndStmt(), getRow());
                // 3. If Object is not in cache
                // materialize Object with primitive attributes filled from current row
                result = rowReader.readObjectFrom(getRow());
                // result may still be null!
                if (result != null)
                {
                    /*
					 * synchronize on result so the ODMG-layer can take a
					 * snapshot only of fully cached (i.e. with all references +
					 * collections) objects
					 */
                    synchronized (result)
                    {
                        getCache().enableMaterializationCache();
                        try
                        {
                            getCache().doInternalCache(oid, result, ObjectCacheInternal.TYPE_NEW_MATERIALIZED);
                            /**
                             * MBAIRD if you have multiple classes mapped to a
                             * table, and you query on the base class you could get
                             * back NON base class objects, so we shouldn't pass
                             * m_cld, but rather the class descriptor for the
                             * actual class.
                             */
                            // fill reference and collection attributes
                            ClassDescriptor cld = getBroker().getClassDescriptor(result.getClass());
                            // don't force loading of reference
                            final boolean unforced = false;
                            // Maps ReferenceDescriptors to HashSets of owners
                            getBroker().getReferenceBroker().retrieveReferences(result, cld, unforced);
                            getBroker().getReferenceBroker().retrieveCollections(result, cld, unforced);
                            getCache().disableMaterializationCache();
                        }
                        catch(RuntimeException e)
                        {
                            // catch runtime exc. to guarantee clearing of internal buffer on failure
                            getCache().doLocalClear();
                            throw e;
                        }
                    }
                }
            }
            else // Object is in cache
            {
                ClassDescriptor cld = getBroker().getClassDescriptor(result.getClass());
                // if refresh is required, read all values from the result set and
                // update the cache instance from the db
                if (cld.isAlwaysRefresh())
                {
                    // map all field values from the current result set
                    rowReader.readObjectArrayFrom(getRsAndStmt(), getRow());
                    rowReader.refreshObject(result, getRow());
                }
                getBroker().checkRefreshRelationships(result, oid, cld);
            }

            return result;
        }
    }
protected Object getObjectFromResultSet ( ) throws PersistenceBrokerException { getRow ( ) . clear ( ) ; RowReader rowReader = getQueryObject ( ) . getClassDescriptor ( ) . getRowReader ( ) ; rowReader . readPkValuesFrom ( getRsAndStmt ( ) , getRow ( ) ) ; if ( getItemProxyClass ( ) != null ) { return getProxyFromResultSet ( ) ; } else { Identity oid = getIdentityFromResultSet ( ) ; Object result ; result = getCache ( ) . lookup ( oid ) ; if ( result == null ) { rowReader . readObjectArrayFrom ( getRsAndStmt ( ) , getRow ( ) ) ; result = rowReader . readObjectFrom ( getRow ( ) ) ; if ( result != null ) { synchronized ( result ) { getCache ( ) . enableMaterializationCache ( ) ; try { getCache ( ) . doInternalCache ( oid , result , ObjectCacheInternal . TYPE_NEW_MATERIALIZED ) ; ClassDescriptor cld = getBroker ( ) . getClassDescriptor ( result . getClass ( ) ) ; final boolean unforced = false ; getBroker ( ) . getReferenceBroker ( ) . retrieveReferences ( result , cld , unforced ) ; getBroker ( ) . getReferenceBroker ( ) . retrieveCollections ( result , cld , unforced ) ; getCache ( ) . disableMaterializationCache ( ) ; } catch ( RuntimeException e ) { getCache ( ) . doLocalClear ( ) ; throw e ; } } } } else { ClassDescriptor cld = getBroker ( ) . getClassDescriptor ( result . getClass ( ) ) ; if ( cld . isAlwaysRefresh ( ) ) { rowReader . readObjectArrayFrom ( getRsAndStmt ( ) , getRow ( ) ) ; rowReader . refreshObject ( result , getRow ( ) ) ; } getBroker ( ) . checkRefreshRelationships ( result , oid , cld ) ; } return result ; } }
returns a fully materialized Object from the current row of the
underlying resultset. Works as follows: - read Identity from the primary
key values of current row - check if Object is in cache - return cached
object or read it from current row and put it in cache