db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From olegn...@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb/broker QueryTest.java
Date Sun, 26 Oct 2003 00:03:21 GMT
olegnitz    2003/10/25 17:03:21

  Modified:    src/test/org/apache/ojb repository.dtd repository.xml
               src/test/org/apache/ojb/broker QueryTest.java
  Log:
  proxy-prefetching-limit attribute added to repository.xml
  prefetching for arrays
  
  Revision  Changes    Path
  1.49      +23 -0     db-ojb/src/test/org/apache/ojb/repository.dtd
  
  Index: repository.dtd
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/repository.dtd,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- repository.dtd	3 Oct 2003 00:37:16 -0000	1.48
  +++ repository.dtd	26 Oct 2003 00:03:21 -0000	1.49
  @@ -35,6 +35,7 @@
   	version (1.0) #REQUIRED
   	isolation-level (read-uncommitted | read-committed | repeatable-read |
   	                 serializable | optimistic) "read-uncommitted"
  +	proxy-prefetching-limit CDATA "50"
   >
   
   <!--
  @@ -337,6 +338,13 @@
   	If set to another value this value is interpreted as the full-qualified
   	name of the proxy class to use.
   
  +    If the proxy-prefetching-limit attribute (used with the proxy attribute)
  +    is set to the value > 0, the collections of objects of this class are materialized
  +    by groups of the specified size, say when user tries to access the first
  +    object of the collection, next proxy-prefetching-limit objects are loaded
  +    by one database query.
  +    Set this parameter to 0 if you want to turn this feature off.
  +
   	The schema attribute may contain the database schema owning the table
   	mapped to this class.
   
  @@ -369,6 +377,7 @@
   	isolation-level (read-uncommitted | read-committed | repeatable-read |
   	                 serializable | optimistic) "read-uncommitted"
   	proxy CDATA #IMPLIED
  +	proxy-prefetching-limit CDATA #IMPLIED
   	schema CDATA #IMPLIED
   	table CDATA #IMPLIED
   	row-reader CDATA #IMPLIED
  @@ -546,6 +555,12 @@
   	The proxy attribute can be set to true to specify that proxy based
   	lazy loading should be used for this attribute.
   
  +    If the proxy-prefetching-limit attribute (used with the proxy attribute)
  +    is set to the value > 0, then loading of the reference for the first
  +    object of some collection causes loading of the references for
  +    the next proxy-prefetching-limit objects.
  +    Set this parameter to 0 if you want to turn this feature off.
  +
   	The refresh attribute can be set to true to force OJB to refresh
   	object references on instance loading.
   
  @@ -574,6 +589,7 @@
   	class-ref IDREF #REQUIRED
   
   	proxy (true | false) "false"
  +	proxy-prefetching-limit CDATA #IMPLIED
   	refresh (true | false) "false"
   
   	auto-retrieve (true | false) "true"
  @@ -651,6 +667,12 @@
   	The proxy attribute can be set to true to specify that proxy based
   	lazy loading should be used for this attribute.
   
  +    If the proxy-prefetching-limit attribute (used with the proxy attribute)
  +    is set to the value > 0, then loading of the collection for the first
  +    object of some other collection causes loading of the collections for
  +    the next proxy-prefetching-limit objects.
  +    Set this parameter to 0 if you want to turn this feature off.
  +
   	The refresh attribute can be set to true to force OJB to refresh
   	object and collection references on instance loading.
   
  @@ -686,6 +708,7 @@
   	indirection-table CDATA #IMPLIED
   
   	proxy (true | false) "false"
  +	proxy-prefetching-limit CDATA #IMPLIED
   	refresh (true | false) "false"
   
   	auto-retrieve (true | false) "true"
  
  
  
  1.18      +2 -1      db-ojb/src/test/org/apache/ojb/repository.xml
  
  Index: repository.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/repository.xml,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- repository.xml	3 Jun 2003 09:20:52 -0000	1.17
  +++ repository.xml	26 Oct 2003 00:03:21 -0000	1.18
  @@ -29,7 +29,8 @@
   ]>
   
   
  -<descriptor-repository version="1.0" isolation-level="read-uncommitted">
  +<descriptor-repository version="1.0" isolation-level="read-uncommitted" 
  +        proxy-prefetching-limit="50">
   
       <!-- include all used database connections -->
       &database;
  
  
  
  1.38      +18 -12    db-ojb/src/test/org/apache/ojb/broker/QueryTest.java
  
  Index: QueryTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/QueryTest.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- QueryTest.java	19 Sep 2003 19:34:05 -0000	1.37
  +++ QueryTest.java	26 Oct 2003 00:03:21 -0000	1.38
  @@ -459,20 +459,15 @@
   	 * prefetch Articles for ProductGroupsWithArray,
   	 * Does not yet work with Arrays
   	 */
  -	public void tesXPrefetchedArraySingleKey()
  +	public void testPrefetchedArraySingleKey()
   	{
  -		fail("Prefetch does not yet work with arrays");
  -
  -		ClassDescriptor cldProductGroup = broker.getClassDescriptor(ProductGroupWithArray.class);
   		ClassDescriptor cldArticle = broker.getClassDescriptor(Article.class);
  -		Class productGroupProxy = cldProductGroup.getProxyClass();
   		Class articleProxy = cldArticle.getProxyClass();
   
   		//
   		// use ProductGroup and Articles with disabled Proxy
   		//
   		broker.clearCache();
  -		cldProductGroup.setProxyClassName(null);
   		cldArticle.setProxyClassName(null);
   
   		Criteria crit = new Criteria();
  @@ -486,13 +481,12 @@
   		assertTrue(results.size() > 0);
   		ProductGroupWithArray pg = (ProductGroupWithArray) results.toArray()[0];
   		int articleSize = pg.getAllArticles().length;
  -		String articleString = pg.getAllArticles().toString();
  +		String articleString = Arrays.asList(pg.getAllArticles()).toString();
   
   		//
   		// use ProductGroupWithArray and Articles with original Proxy settings
   		//
   		broker.clearCache();
  -		cldProductGroup.setProxyClassName(productGroupProxy.getName());
   		cldArticle.setProxyClassName(articleProxy.getName());
   
   		crit = new Criteria();
  @@ -500,8 +494,15 @@
   		q = QueryFactory.newQuery(ProductGroupWithArray.class, crit);
   		results = broker.getCollectionByQuery(q);
   		ProductGroupWithArray pg2 = (ProductGroupWithArray) results.toArray()[0];
  -		int articleSize2 = pg2.getAllArticles().length;
  -		String articleString2 = pg2.getAllArticles().toString();
  +        InterfaceArticle[] articles = pg2.getAllArticles();
  +
  +        // force materialization
  +        for (int i = 0; i < articles.length; i++)
  +        {
  +            articles[i].getArticleName();
  +        }
  +		int articleSize2 = articles.length;
  +		String articleString2 = Arrays.asList(articles).toString();
   
   		//
   		// compare prefetched and 'normal' data
  @@ -563,14 +564,19 @@
   		q = QueryFactory.newQuery(ProductGroup.class, crit);
   		results = broker.getCollectionByQuery(q);
   		InterfaceProductGroup pg2 = (InterfaceProductGroup) results.toArray()[0];
  +        // force materialization
  +        for (Iterator it = pg2.getAllArticles().iterator(); it.hasNext(); )
  +        {
  +            ((InterfaceArticle) it.next()).getArticleName();
  +        }
   		int articleSize2 = pg2.getAllArticles().size();
   		String articleString2 = pg2.getAllArticles().toString();
   
   		//
   		// compare prefetched and 'normal' data
   		//
  -		assertEquals("Check size", articleSize, articleSize2);
  -		assertEquals("Check content", articleString, articleString2);
  +        assertEquals("Check size", articleSize, articleSize2);
  +        assertEquals("Check content", articleString, articleString2);
   	}
   
   	/**
  
  
  

---------------------------------------------------------------------
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