db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r371091 - in /db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides: advanced-technique.xml repository.xml
Date Sat, 21 Jan 2006 17:38:23 GMT
Author: arminw
Date: Sat Jan 21 09:38:15 2006
New Revision: 371091

URL: http://svn.apache.org/viewcvs?rev=371091&view=rev
Log:
add notes about declaration of RowReader

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/advanced-technique.xml
    db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/repository.xml

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/advanced-technique.xml
URL: http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/advanced-technique.xml?rev=371091&r1=371090&r2=371091&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/advanced-technique.xml
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/advanced-technique.xml
Sat Jan 21 09:38:15 2006
@@ -1333,8 +1333,17 @@
             </ul>
             <p>
                 RowReader setting on <em>class-descriptor</em> level will override
the standard
-                reader set in <code>OJB.properties</code> file. If neither a
RowReader was set in
-                OJB.properties file nor in class-descriptor was set, OJB use an default implementation.
+                reader set in <code>OJB.properties</code> file.
+            </p>
+            <note>
+                Please read carefully the notes about using <em>RowReader</em>
on class level
+                (and specific handling in class hierarchies) in 
+                <a href="site:repository/class-descriptor">class-descriptor section</a>.
+            </note>
+            <p>
+                If neither a RowReader was set in
+                OJB.properties file nor in <a href="site:repository/class-descriptor">class-descriptor</a>
+                was set, OJB use an default implementation.
             </p>
             <p>
                 To understand how to use them we must know some of the details of the load
mechanism.
@@ -1353,101 +1362,21 @@
             <source><![CDATA[
 protected Object getObjectFromResultSet() throws PersistenceBrokerException
 {
-    if (getItemProxyClass() != null)
-    {
-        // provide m_row with primary key data of current row
-        getQueryObject().getClassDescriptor().getRowReader()
-                    .readPkValuesFrom(getRsAndStmt().m_rs, getRow());
-        // assert: m_row is filled with primary key values from db
-        return getProxyFromResultSet();
-    }
-    else
-    {
-        // 0. provide m_row with data of current row
-        getQueryObject().getClassDescriptor().getRowReader()
-                    .readObjectArrayFrom(getRsAndStmt().m_rs, getRow());
-        // assert: m_row is filled from db
-
-        // 1.read Identity
-        Identity oid = getIdentityFromResultSet();
-        Object result = null;
-
-        // 2. check if Object is in cache. if so return cached version.
-        result = getCache().lookup(oid);
-        if (result == null)
-        {
-            // 3. If Object is not in cache
-            // materialize Object with primitive attributes filled from
-            // current row
-            result = getQueryObject().getClassDescriptor()
-                                        .getRowReader().readObjectFrom(getRow());
-            // result may still be null!
-            if (result != null)
-            {
-                synchronized (result)
-                {
-                    getCache().enableMaterializationCache();
-                    getCache().cache(oid, result);
-                    // fill reference and collection attributes
-                    ClassDescriptor cld = getQueryObject().getClassDescriptor()
-                            .getRepository().getDescriptorFor(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();
-                }
-            }
-        }
-        else // Object is in cache
-        {
-            ClassDescriptor cld = getQueryObject().getClassDescriptor()
-                        .getRepository().getDescriptorFor(result.getClass());
-            // if refresh is required, update the cache instance from the db
-            if (cld.isAlwaysRefresh())
-            {
-                getQueryObject().getClassDescriptor()
-                                    .getRowReader().refreshObject(result, getRow());
-            }
-            getBroker().refreshRelationships(result, cld);
-        }
-        return result;
-    }
+    ...
+    RowReader rowReader = getQueryObject().getClassDescriptor().getRowReader();
+    ...
+    return result;
 }]]></source>
             <p>
                 This method first uses a RowReader to instantiate a new object array
                 and to fill it with primitive attributes from the
                 current ResultSet row.
                 <br/>
-                The RowReader to be used for a Class can be configured in the XML
-                repository with the attribute
+                The RowReader to be used for a Class can be configured in the
+                <a href="site:repository">metadata repository</a> with the attribute
                 <a href="site:repository/class-descriptor"><code>row-reader</code></a>.
-                If no RowReader is specified, the standard <code>RowReader</code>
is used. The
-                method
-                <code>readObjectArrayFrom(...)</code> of this class looks like
follows:
+                If no RowReader is specified, the standard <code>RowReader</code>
is used.
             </p>
-            <source><![CDATA[
-public void readObjectArrayFrom(ResultSet rs, ClassDescriptor cld, Map row)
-{
-    try
-    {
-        Collection fields = cld.getRepository().
-                        getFieldDescriptorsForMultiMappedTable(cld);
-        Iterator it = fields.iterator();
-        while (it.hasNext())
-        {
-            FieldDescriptor fmd = (FieldDescriptor) it.next();
-            FieldConversion conversion = fmd.getFieldConversion();
-            Object val = JdbcAccess.getObjectFromColumn(rs, fmd);
-            row.put(fmd.getColumnName() , conversion.sqlToJava(val));
-        }
-    }
-    catch (SQLException t)
-    {
-        throw new PersistenceBrokerException("Error reading from result set",t);
-    }
-}]]></source>
             <p>
                 In the second step OJB checks if there is
                 already a cached version of the object to materialize.

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/repository.xml
URL: http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/repository.xml?rev=371091&r1=371090&r2=371091&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/repository.xml
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/repository.xml
Sat Jan 21 09:38:15 2006
@@ -1068,10 +1068,22 @@
                     The <em>table</em> attribute speciefies the table name this
class is mapped to.
                 </p>
                 <p>
-                    The <em>row-reader</em> attribute may contain a full qualified
class name. This class will be
-                    used as the <a href="site:advanced-technique/using-rowreader">RowReader</a>
implementation used
-                    to materialize instances of the persistent class.
+                    The <em>row-reader</em> attribute may contain a full qualified
class name. The specified
+                    class will be used as the <a href="site:advanced-technique/using-rowreader">RowReader</a>
+                    implementation which materialize instances of the persistent class.
+                    <br/>
+                    If not set always the default implementation specified in
+                    <a href="site:ojb-properties">OJB.prperties</a> file will
be used.
                 </p>
+                <note>
+                    Setting a specific <em>RowReader</em> (on class level) for
a class using some kind of
+                    <a href="site:advanced-technique/polymorphism">Polymorphism or
Inheritance</a>
+                    it's strongly recommended to set the same <em>RowReader</em>
for each class in the
+                    inheritance class graph. When OJB materialize the associated object of
a result set row
+                    it always use the <em>RowReader</em> of the class specified
in the query, e.g. the
+                    <em>RowReader</em> defined in the base class or interface
of the class graph or a
+                    sub-class in the "middle" of the hierarchy.
+                </note>
                 <p>
                     The <em>extends</em> attribute is <strong>deprecated</strong>
and will be removed
                     or reintroduced with changed funcitonality in future. DON'T USE IT!



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message