db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject cvs commit: db-ojb/xdocs faq.xml
Date Sun, 22 Jun 2003 20:50:14 GMT
thma        2003/06/22 13:50:14

  Modified:    xdocs    faq.xml
  add more faq entries....
  Revision  Changes    Path
  1.24      +61 -0     db-ojb/xdocs/faq.xml
  Index: faq.xml
  RCS file: /home/cvs/db-ojb/xdocs/faq.xml,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- faq.xml	20 Jun 2003 07:29:59 -0000	1.23
  +++ faq.xml	22 Jun 2003 20:50:14 -0000	1.24
  @@ -67,6 +67,9 @@
   	<li><a href="#How to map a list of Strings">How to map a list of Strings</a></li>
   	<li><a href="#How to set up Optimistic Locking">How to set up Optimistic Locking</a></li>
   	<li><a href="#How to use OJB in a cluster">How to use OJB in a cluster</a></li>
  +	<li><a href="#How to work with the ObjectCacheEmptyImpl">How to work with
the ObjectCacheEmptyImpl</a></li>
  +	<li><a href="#Why must my persisten class implement javax.jdo.spi.PersistenceCapable">Why
must my persisten class implement javax.jdo.spi.PersistenceCapable</a></li>
  @@ -1353,6 +1356,64 @@
   			complete howto document</a>
   			 available that covers these topics.
  +	</subsection>
  +	<subsection name="How to work with the ObjectCacheEmptyImpl">
  +		<p>
  +			<b>Q: </b>I just tried to turn caching off by using ObjectCacheEmptyImpl
  +			in ObjectCacheClass, and it seems to continuously loop through the SQL
  +			statement infinitely.  The default works fine though.
  +			<br/>
  +			Any ideas why this might be?
  +		</p>
  +		<p>
  +			<b>A: </b>The Problem you see is due to circular references in your data.
  +			Say A references B and B has a backreference to A.
  +			<br/>
  +			Now we load A from the DB. If autoretrieve="true" for the reference-descriptor 
  +			defining the reference to B, OJB will also load B.
  +			If autoretrieve="true" for the B-reference-descriptor describing 
  +			the back-reference to A, OJB must retrieve A. And here is the key point.
  +			<br/>
  +			If we use the defaultcache A will be in the cache already, as it was loaded first. 
  +			So OJB will simply lookup A from the cache. No endless recursion!
  +			<br/>
  +			But if we use the emptycache, A will not be cached. So OJB must load A from the DB.

  +			And then again B is retrieved, etc., etc.
  +			There's you endless recursion.
  +			<br/>
  +			In other words: A non-empty cache is needed to allow proper loading of circular 
  +			references. (Other O/R tools like TopLink work the same way).
  +			<br/>
  +			If you still want to use the EmptyCacheImpl you should set autoretrieve="false" 
  +			and load references explicitely by broker.retrieveReference(...).		
  +		</p>
  +	</subsection>
  +	<subsection name="Why must my persisten class implement javax.jdo.spi.PersistenceCapable">
  +		As specified by JDO all persistent classe must implement the interface 
  +		<code>javax.jdo.spi.PersistenceCapable</code>.
  +		If a class does not implement this interface a JDO implementation does not know how to

  +		handle it.
  +		<br/>
  +		On the other hand the JDO spec claims to provide transaparent persistence. 
  +		That is no persistence class is required to implement a specific interface or 
  +		to be derived from a special base class.
  +		<br/>
  +		Sounds like a contradiction? It is! The JDO spec resolves this contradiction by 
  +		stating that a JDO implemention is responsible to add the methods required by 
  +		<code>javax.jdo.spi.PersistenceCapable</code> to the the user classes. 
  +		This "injection" could be achieved by Pre- or Post-processing. 
  +		The strategy most implementations use is called "bytecode-enhancement". 
  +		This is a postprocesing step that adds the required methods to the .class files 
  +		of the persistent user classes.
  +		<br/>
  +		The JDO Reference implementation also uses bytecode-enhancement.
  +		In order to enhance the Product class to implement the 
  +		<code>javax.jdo.spi.PersistenceCapable</code> interface use the ant target

  +		"enhance-jdori" before launching the tutorial5 application.
  +		This is documentated in the first section of tutorial4.html.

View raw message