db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattba...@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb/odmg OQLTest.java
Date Tue, 24 Jun 2003 21:45:21 GMT
mattbaird    2003/06/24 14:45:21

  Modified:    src/test/org/apache/ojb/odmg OQLTest.java
  Log:
  add prefetching functionality to OQL. prefetch statements should be comma separated at the
end of the query. ie: 
  
  select allProductGroups from " + ProductGroup.class.getName() + " where groupId <= $1
order by groupId prefetch allArticlesInGroup
  
  Revision  Changes    Path
  1.11      +29 -3     db-ojb/src/test/org/apache/ojb/odmg/OQLTest.java
  
  Index: OQLTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/odmg/OQLTest.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- OQLTest.java	24 Jun 2003 20:49:48 -0000	1.10
  +++ OQLTest.java	24 Jun 2003 21:45:21 -0000	1.11
  @@ -90,9 +90,17 @@
   			db.deletePersistent(it.next());
   		}
   		tx.commit();
  -		allAnimals = (Collection) query.execute();
  -		System.out.println("animals is: " + allAnimals.size());
  -		assertTrue("should be no animals", (allAnimals.size() ==0));
  +
  +		tx = odmg.newTransaction();
  +		tx.begin();
  +		query.create("select allFoods from " + InterfaceFood.class.getName());
  +		Collection allFoods = (Collection) query.execute();
  +		it = allFoods.iterator();
  +		while (it.hasNext())
  +		{
  +			db.deletePersistent(it.next());
  +		}
  +		tx.commit();
   	}
   
   	/**
  @@ -264,6 +272,24 @@
   		List animals = (List) query.execute();
   		tx.commit();
   		assertEquals(3, animals.size());
  +	}
  +
  +	public void testPrefetchQuery() throws Exception
  +	{
  +		String oql = "select allProductGroups from " + ProductGroup.class.getName() + " where
groupId <= $1 order by groupId prefetch allArticlesInGroup";
  +		Implementation odmg = OJB.getInstance();
  +		Database db = odmg.newDatabase();
  +		db.open(databaseName, Database.OPEN_READ_WRITE);
  +		OQLQuery query = odmg.newOQLQuery();
  +		query.create(oql);
  +		query.bind(new Integer(5));
  +		Transaction tx = odmg.newTransaction();
  +		tx.begin();
  +		Collection results = (Collection) query.execute();
  +		tx.commit();
  +		db.close();
  +		assertNotNull(results);
  +		assertTrue(results.size() > 0);
   	}
   
   	public void testInterfaceQuery() throws Exception
  
  
  

Mime
View raw message