Uploaded image for project: 'Hibernate ODM'
  1. Hibernate ODM
  2. HIBERNATE-40

Improve MongoStatement's #executeUpdate(String) implementation

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • 5
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      In https://jira.mongodb.org/browse/HIBERNATE-16, we implemented basic `executeUpdate()` as following:

      @Override
      public int executeUpdate(String mql) throws SQLException {
          checkClosed();
          var command = parse(mql);
          try {
              mongoConnection.startTransactionIfNeeded();
              return mongoClient
                      .getDatabase(DATABASE)
                      .runCommand(clientSession, command)
                      .getInteger("n");
          } catch (Exception e) {
              throw new SQLException("Failed to run #executeUpdate(String)", e);
          }
      } 

      It is painfully simplistic for `runCommand` is insufficient for many reasons, including:

      • Retryability for non-transaction writes (exemplified in POC project)
      • Exception translation
      • any other things

      If we use CRUD API for item #1 above, retrying mechanism has been done already; however, we need to decide whether we only support CRUD APIs for native MQL.

      When implementing this, we should keep in mind that our MongoTimeoutException (((MongoOperationTimeoutException}} is its subclass), MongoExecutionTimeoutException should probably turned into SQLTimeoutException, as executeUpdate is explicitly documented to throw SQLTimeoutException.

      See also

            Assignee:
            nathan.xu@mongodb.com Nathan Xu
            Reporter:
            nathan.xu@mongodb.com Nathan Xu
            None
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: