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

		// create some test data
		BeforeBottom bb = new BeforeBottom();
		bb.setFoo(new OriginalObject());
		pm.saveObject(bb);
		bb = new BeforeBottom();
		bb.setFoo(new OriginalObject());
		pm.saveObject(bb);

		// move a field up in the hierarchy
		TestTools tt = new TestTools(pm.getPersist());
		tt.changeName(BeforeBottom.class, AfterBottom.class);
		tt.changeName(BeforeTop.class, AfterTop.class);
		pm.updateSchema(AfterBottom.class);
		pm.close();

		// check that the protection entry has been updated to point from the
		// new containing class
		pm = new PersistenceManager(driver, database, login, password);
		ConnectionWrapper cw = pm.getConnectionWrapper();
		StringBuilder query = new StringBuilder("SELECT COUNT(*) FROM ");
		query.append(Defaults.HAS_A_TABLENAME);
		query.append(" WHERE OWNER_TABLE = ? AND PROPERTY_TABLE = ?");
		PreparedStatement ps = cw.prepareStatement(query.toString());
		AdapterBase adapter = pm.getPersist().getAdapter();
		NameGenerator.getTableName(AfterTop.class, adapter);
		ps.setInt(1, adapter.getPersist().getTableNameNumberMap().getNumber(cw, AfterTop.class));
		ps.setInt(2, adapter.getPersist().getTableNameNumberMap().getNumber(cw, OriginalObject.class));

		ResultSet rs = ps.executeQuery();
		if (rs.next())
		{
			assertEquals(2, rs.getInt(1));
		} 
		else
		{
			fail("No results returned");
		}
		ps.close();
		
		//check that the old protection entries are gone
		ps = cw.prepareStatement(query.toString());
		ps.setInt(1, adapter.getPersist().getTableNameNumberMap().getNumber(cw,AfterBottom.class));
		ps.setInt(2, adapter.getPersist().getTableNameNumberMap().getNumber(cw,OriginalObject.class));
		rs = ps.executeQuery();
		if (rs.next())
		{
			assertEquals(0, rs.getInt(1));
		} 
		else
		{
			fail("No results returned");
		}
		ps.close();
		pm.close();
	}