Ejemplo n.º 1
0
  /**
   * Add/update a table's penalty.
   *
   * @param table
   * @param penalties
   */
  public static void addOrUpdateAll(Table table) throws FatalException {

    // delete penalties for which values are all null
    List<Penalty> tablePenalties = table.getPenalties();
    for (Iterator<Penalty> iterator = tablePenalties.iterator(); iterator.hasNext(); ) {
      Penalty penalty = (Penalty) iterator.next();
      if (penalty != null
          && penalty.getPenaltyPlayer1() == null
          && penalty.getPenaltyPlayer2() == null
          && penalty.getPenaltyPlayer3() == null
          && penalty.getPenaltyPlayer4() == null) {
        iterator.remove();
      }
    }

    HibernateUtil.save(table);
  }
Ejemplo n.º 2
0
  /**
   * Remove a table's penalty.
   *
   * @param table
   * @param penalty
   * @throws FatalException
   */
  public static void deleteAll(Table table) throws FatalException {
    List<Penalty> tablePenalties = table.getPenalties();
    tablePenalties.clear();

    HibernateUtil.save(table);
  }