ExportXMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: 1.50.0
    • Component/s: None
    • Environment:
      OS:
      node.js / npm versions: 24 / 11
      Additional info:MongoDB Compass built from the current main branch.
    • None
    • None
    • Developer Tools

      Problem Statement/Rationale

      The Java Export to Language feature currently has two issues:

      1. It generates connection code using the legacy Java Driver API:

       

      import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; MongoClient mongoClient = new MongoClient( new MongoClientURI("mongodb://localhost:27017/") );

       

      Applications using the current mongodb-driver-sync dependency do not have access to these legacy classes by default. The generated code should use the current Java Driver API:

       

      import com.mongodb.client.MongoClient; import com.mongodb.client.MongoClients; MongoClient mongoClient = MongoClients.create( "mongodb://localhost:27017/" );

       

      1. When Max Time MS is configured in Compass, the value is not included in the generated Java code.

      The Java exporter should generate code that reflects both the current Java Driver API and the Max Time MS option configured in Compass.

      Steps to Reproduce

      1. Open MongoDB Compass.
      2. Connect to a deployment.
      3. Open a collection.
      4. Create a query or aggregation.
      5. Use Export to Language and select Java.
      6. Observe that the generated connection code uses MongoClientURI and new MongoClient(...).
      7. Configure a value for Max Time MS.
      8. Export the query to Java again.
      9. Observe that the Max Time MS setting is not included in the generated Java code.

      Expected Results

      The generated Java code should:

      • Use the current MongoDB Java Driver API with com.mongodb.client.MongoClient and MongoClients.create(...).
      • Include the configured Max Time MS value in the generated Java operation.

      Actual Results

      The generated Java code:

      • Uses the legacy com.mongodb.MongoClient and MongoClientURI APIs.
      • Does not include the Max Time MS setting selected in Compass.

      Additional Notes

      Both issues are related to the Java Export to Language functionality and can be addressed in the same change.

            Assignee:
            Unassigned
            Reporter:
            Ricardo Silva de Mello
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: