@Override
  public Answer update(BuildRevisionBatch buildRevisionBatch) {
    MessageEvent msg = null;
    final String query =
        "UPDATE buildrevisionbatch SET system = ?, Country = ?, Environment = ?, Build = ?, Revision = ?, "
            + "Batch = ?  WHERE id = ? ";

    // Debug message on SQL.
    if (LOG.isDebugEnabled()) {
      LOG.debug("SQL : " + query);
    }
    Connection connection = this.databaseSpring.connect();
    try {
      PreparedStatement preStat = connection.prepareStatement(query);
      try {
        preStat.setString(1, buildRevisionBatch.getSystem());
        preStat.setString(2, buildRevisionBatch.getCountry());
        preStat.setString(3, buildRevisionBatch.getEnvironment());
        preStat.setString(4, buildRevisionBatch.getBuild());
        preStat.setString(5, buildRevisionBatch.getRevision());
        preStat.setString(6, buildRevisionBatch.getBatch());
        preStat.setLong(7, buildRevisionBatch.getId());

        preStat.executeUpdate();
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
        msg.setDescription(
            msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "UPDATE"));
      } catch (SQLException exception) {
        LOG.error("Unable to execute query : " + exception.toString());
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
        msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
      } finally {
        preStat.close();
      }
    } catch (SQLException exception) {
      LOG.error("Unable to execute query : " + exception.toString());
      msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
      msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
    } finally {
      try {
        if (connection != null) {
          connection.close();
        }
      } catch (SQLException exception) {
        LOG.error("Unable to close connection : " + exception.toString());
      }
    }
    return new Answer(msg);
  }
  @Override
  public Answer create(BuildRevisionBatch buildRevisionBatch) {
    MessageEvent msg = null;
    StringBuilder query = new StringBuilder();
    query.append(
        "INSERT INTO buildrevisionbatch (`system`, `Country`, `Environment`, `Build`, `Revision`, `Batch` ) ");
    query.append("VALUES (?,?,?,?,?,?)");

    // Debug message on SQL.
    if (LOG.isDebugEnabled()) {
      LOG.debug("SQL : " + query.toString());
    }
    Connection connection = this.databaseSpring.connect();
    try {
      PreparedStatement preStat = connection.prepareStatement(query.toString());
      try {
        preStat.setString(1, buildRevisionBatch.getSystem());
        preStat.setString(2, buildRevisionBatch.getCountry());
        preStat.setString(3, buildRevisionBatch.getEnvironment());
        preStat.setString(4, buildRevisionBatch.getBuild());
        preStat.setString(5, buildRevisionBatch.getRevision());
        preStat.setString(6, buildRevisionBatch.getBatch());

        preStat.executeUpdate();
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
        msg.setDescription(
            msg.getDescription().replace("%ITEM%", OBJECT_NAME).replace("%OPERATION%", "INSERT"));

      } catch (SQLException exception) {
        LOG.error("Unable to execute query : " + exception.toString());

        if (exception
            .getSQLState()
            .equals(SQL_DUPLICATED_CODE)) { // 23000 is the sql state for duplicate entries
          msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_DUPLICATE);
          msg.setDescription(
              msg.getDescription()
                  .replace("%ITEM%", OBJECT_NAME)
                  .replace("%OPERATION%", "INSERT")
                  .replace("%REASON%", exception.toString()));
        } else {
          msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
          msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
        }
      } finally {
        preStat.close();
      }
    } catch (SQLException exception) {
      LOG.error("Unable to execute query : " + exception.toString());
      msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
      msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
    } finally {
      try {
        if (connection != null) {
          connection.close();
        }
      } catch (SQLException exception) {
        LOG.warn("Unable to close connection : " + exception.toString());
      }
    }
    return new Answer(msg);
  }