[cvs] expresso/expresso-web/expresso/doc/edg dbobject-types.xml

JCorporate Ltd jcorp at jcorp2.servlets.net
Sun Jul 4 09:41:52 PDT 2004


Update of /home/javacorp/.cvs/expresso/expresso/expresso-web/expresso/doc/edg
In directory jcorp2.servlets.net:/tmp/cvs-serv12259/expresso-web/expresso/doc/edg

Modified Files:
	dbobject-types.xml 
Log Message:
add info about dynamic JoinedDB usage


Index: dbobject-types.xml
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/expresso/doc/edg/dbobject-types.xml,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** dbobject-types.xml	2 Jun 2004 19:17:27 -0000	1.15
--- dbobject-types.xml	4 Jul 2004 16:41:49 -0000	1.16
***************
*** 47,51 ****
  			<para>
  As of Expresso 5.1, it is recommended that new developers work with JoinedDataObject
! due to its increased flexibility and speed over MultiDBObject
  			</para>
  		</note>
--- 47,52 ----
  			<para>
  As of Expresso 5.1, it is recommended that new developers work with JoinedDataObject
! due to its increased flexibility and speed over MultiDBObject. However, MultiDBObject will remain
!                 supported for the foreseeable future, since it is used quite a bit in existing applications.
  			</para>
  		</note>
***************
*** 444,450 ****
  			</para>
  		</sect2>
  	</sect1>
  	<sect1>
! 		<title>MediaDBObject [Since Expresso 5.1]</title>
  		<indexterm>
  			<primary>MediaDBObject</primary>
--- 445,538 ----
  			</para>
  		</sect2>
+         <sect2>
+         <title>Using JoinedDigesterBean for polymorphism</title>
+         <para>Question: I'm trying to make a JoinedDataObject within
+ RowSecuredDBObject.searchAndRetrieveList() which will help do security
+ checks w/i DB, rather than as N tests after getting the list. But RowSecuredDBObject is the superclass.  The real join is on the subclass.
+ In MultiDBObject, I can use getInstance(), but in the XML for
+ JoinedDataObject, I think I'm out of luck.
+         </para>
+         <para>Answer:
+         You can provide a populated JoinedDigesterBean instance that is
+ built on the fly that gives you the query capabilities:         </para>
+ 
+ <programlisting><![CDATA[
+ JoinedDigesterBean bean = new JoinedDigesterBean();
+ bean.setName("RowPermissions/" + this.getClass().getName());
+ bean.addDataObject(this.getClass().getName(),null,"class1");
+ bean.addDataObject(myClassTwo, null,"class2");
+ bean.addRelation(....  [API mirrors XML]);
+ 
+ JoinedDataObject jdo = new JoinedDataObject(bean, "RowPermissions/" +
+                         this.getClass().getName());
+ ]]></programlisting>
+ 
+ <para>
+ Because it's expensive to initialize metadata, each ad-hoc join will need a
+ distinct name since the metadata is cached.  However, after the initial
+ build, then you get:
+ </para>
+ 
+ <programlisting><![CDATA[
+ JoinedDataObject jdo = new JoinedDataObject("RowPermissions/" +
+                             this.getClass().getName());
+ ]]></programlisting>
+ 
+ <para>
+ And you will get a JoinedDataObject with the definition previously defined.
+ </para>
+ 
+ <para>
+ [Begin API Dreaming]
+ In reality, what is really needed is a "JoinedDigesterBean Builder" in the
+ form of a query specification object.  It would be similar, but less
+ powerful than the Hibernate "Criteria" API.
+ 
+ 
+ Off the top of my head pseudocode:
+ </para>
+ 
+ <programlisting><![CDATA[
+ QueryObject query = dataObject.buildQuery();
+ 
+ query = query.criteria(example(dbobject1)
+             .and(example(dbobject2))
+             .and(example(dbobject3)));
+ query = query.firstRow(30).numRows(60);
+ 
+ 
+ 
+ query = query.criteria(
+             field(DBObject1.class,"fieldName",value)
+                 .and(DBObject2.class,"fieldName2", value2));
+ 
+ 
+ // etc.
+ 
+ //Make implementation of List a 'lazy list' that keeps returning
+ //values until end of Recordset or until
+ //query.close() is called
+ try {
+     List result = query.execute();
+     for (Iterator i = result.iterator(); i.hasNext();) {
+         DataObject eachObject = (
+         ....
+     }
+ } finally {
+     query.close();
+ }
+ ]]></programlisting>
+ 
+ <para>
+ Now, I think the only real problem with the above is that I don't think we
+ embed enough relationship metadata within DBObjects to have the dataobject
+ API automatically navigate the relations.  So DataObject API metadata may
+ need some steroids. :)
+ 
+ </para>
+ </sect2>
  	</sect1>
  	<sect1>
!         <title>MediaDBObject [Since Expresso 5.1]</title>
  		<indexterm>
  			<primary>MediaDBObject</primary>



More information about the cvs mailing list