@Test
	public void testIterativeSearch() throws Exception
	{
		PersistenceManager pm = new PersistenceManager(driver, database, login, password);
		// drop all tables
		pm.dropTable(Object.class);

		// create 42 simpleobjects
		final int testCount = 42;
		for (int x = 0; x < testCount; x++)
		{
			SimpleObject so = new SimpleObject();
			// reverse order of COUNT column relative to C__ID
			so.setCount(testCount - x);
			pm.saveObject(so);
		}

		// make sure all objects are still there
		assertEquals(testCount, pm.getCount(SimpleObject.class, new All()));

		// use an array to get around inner class limitations
		final int[] numberFound = new int[2];
		// find all objects
		pm.getObjects(SimpleObject.class, new SearchListener<SimpleObject>()
		{
			@Override
			public void objectFound(SimpleObject object)
			{
				if (numberFound[0] > 0)
				{
					// check that we're going descending order
					assertEquals(numberFound[1] - 1, object.getCount());
				}
				numberFound[0]++;
				numberFound[1] = object.getCount();
			}
		}, new All());
		assertEquals(testCount, numberFound[0]);

		// get a subset of finds, ordered by COUNT column
		final int startAt = 5;
		final int totalCount = 26;
		SimpleObject orderObject = new SimpleObject();
		orderObject.setCount(1);
		numberFound[0] = 0;
		numberFound[1] = startAt;
		pm.getObjects(SimpleObject.class, new SearchListener<SimpleObject>()
		{
			@Override
			public void objectFound(SimpleObject object)
			{
				// check that we're going ascending order
				assertEquals(numberFound[1] + 1, object.getCount());
				numberFound[0]++;
				numberFound[1] = object.getCount();
			}
		}, new All(), new Order(totalCount, startAt, new Ascending(orderObject)));
		assertEquals(totalCount, numberFound[0]);
		
		//make sure we get the all objects when we search by superclass
		numberFound[0] = 0;
		numberFound[1] = 0;
		pm.getObjects(Object.class, new SearchListener<Object>()
		{
			@Override
			public void objectFound(Object o)
			{
				if (o instanceof SimpleObject)
				{
					SimpleObject object = (SimpleObject) o;
					if (numberFound[0] > 0)
					{
						// check that we're going descending order
						assertEquals(numberFound[1] - 1, object.getCount());
					}
					numberFound[0]++;
					numberFound[1] = object.getCount();
				}
			}
		}, new All());
		assertEquals(testCount, numberFound[0]);

		pm.close();
		

		//make sure we get the all objects when we search by superclass, even from a new PM
		pm = new PersistenceManager(driver, database, login, password);
		numberFound[0] = 0;
		numberFound[1] = 0;
		pm.getObjects(Object.class, new SearchListener<Object>()
		{
			@Override
			public void objectFound(Object o)
			{
				if (o instanceof SimpleObject)
				{
					SimpleObject object = (SimpleObject) o;
					if (numberFound[0] > 0)
					{
						// check that we're going descending order
						assertEquals(numberFound[1] - 1, object.getCount());
					}
					numberFound[0]++;
					numberFound[1] = object.getCount();
				}
			}
		}, new All());
		assertEquals(testCount, numberFound[0]);

		pm.close();
	}