/**
  * Check that a table or view is still valid.
  *
  * @param tableOrView the table or view to check
  */
 private void checkViewsAreValid(DbObject tableOrView) {
   for (DbObject view : tableOrView.getChildren()) {
     if (view instanceof TableView) {
       String sql = ((TableView) view).getQuery();
       // check if the query is still valid
       // do not execute, not even with limit 1, because that could
       // have side effects or take a very long time
       session.prepare(sql);
       checkViewsAreValid(view);
     }
   }
 }