public void insertObjects(ConnectionWrapper cw, ProtectionManager protectionManager)
			throws SQLException
	{
		ArrayList<InsertionObject> toRemove = new ArrayList<InsertionObject>();
		for (InsertionObject i : buffer)
		{
			// insert the object
			Long id = persist.saveObjectUnprotected(cw, i.getInsertionObject(), this);
			// get the object id
			if (id != null)
			{
				// update the referring table entry
				StringBuilder sb = new StringBuilder("UPDATE ");
				sb.append(i.getTableName());
				sb.append(" SET ");
				sb.append(i.getColumnName());
				sb.append(" = ?");
				sb.append(" WHERE ");
				sb.append(Defaults.ID_COL);
				sb.append(" = ?");
				PreparedStatement ps = cw.prepareStatement(sb.toString());
				ps.setLong(1, id);
				ps.setLong(2, i.getParentId());
				Tools.logFine(ps);
				try
				{
					int updated = ps.executeUpdate();
					// make sure only one object was updated.
					if (updated != 1)
					{
						throw new SQLException("Updated " + updated + ", not 1.");
					}
					// add a protection entry
					String tableName = null;
					if (i.getReferenceType().isArray())
					{
						tableName = NameGenerator.getArrayTablename(persist.getAdapter());
					}
					else
					{
						tableName = NameGenerator.getTableName(i.getReferenceType(),
								persist.getAdapter());
					}
					protectionManager.protectObjectInternal(i.getTableName(), i
							.getParentId(), i.getColumnName(), tableName, id,
							NameGenerator.getSystemicName(i.getInsertionObject()
									.getClass()), cw);

					// if the object was successfully inserted, remove it
					// from the buffer.
					toRemove.add(i);
				}
				finally
				{
					ps.close();
				}
			}
		}
		for (InsertionObject i : toRemove)
		{
			buffer.remove(i);
		}

	}