Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3665

Allow subclasses of groovy.sql.Sql to get ResultSet

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6.4, 1.7-beta-1
    • 1.6.5, 1.7-beta-2
    • SQL processing
    • None
    • Patch

    Description

      In order for applications to perform optimally where multiple, large databases are in use, it can be important to iterate through a result set without using a closure. One use case is a merge of records from multiple databases: the company has several divisions and each has a an order database, each day, the orders for each SKU must be totalled across all divisions.

      The desired solution is to submit a query to each of the databases in parallel.

      String query = "select SKU, sum(Qty) from OrderItems group by SKU, order by SKU"

      The results from the various DBs are then combined using a merge algorithm.

      This cannot be accomplished with the current API, since it's impractical to load the results of the queries into List objects as is done by the rows(...) methods.

      The attached patch provides a path to implementing the desired solution by adding new protected methods. It also refactors to consolidate logic and remove an exposure to NPE. In addition to new protect methods, a static method to create a List from a ResultSet is made public and the log field is made static.

      The patch includes a new test case added to SqlTest.groovy

      Attachments

        1. SqlResutlSet.patch
          22 kB
          jwb

        Activity

          People

            paulk Paul King
            jwb jwb
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: