Uploaded image for project: 'iBatis for .NET'
  1. iBatis for .NET
  2. IBATISNET-208

Additional documentation for section 3.5.13 when explaining the groupBy attribute

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • DataMapper 1.6
    • DataMapper 1.6
    • DataMapper
    • None
    • Documentation

    Description

      IMHO the current documentation does not provide enough information about what the groupBy attribute is doing. I suggest that additional documentation be provided that shows an example of the data returned from the example query and how the groupBy is applied to that data.

      Something like...

      Category Table
      --------------
      CAT_ID CAT_DESCRIPTION
      1 Category1
      2 Category2
      3 Category3
      4 Category4

      Product Table
      -------------
      PRD_ID PRD_DESCRIPTION PRD_CAT_ID
      1 Product1 1
      2 Product2 1
      3 Product3 null
      4 Product4 2
      5 Product5 2
      6 Product6 3

      The query:
      select C.CAT_ID, C.CAT_DESCRIPTION, P.PRD_ID, P.PRD_DESCRIPTION
      from CATEGORY C
      left outer join PRODUCT P
      on C.CAT_ID = P.PRD_CAT_ID
      where CAT_ID = #value#

      Returns:
      C.CAT_ID C.CAT_DESCRIPTION P.PRD_ID P.PRD_DESCRIPTION
      1 Category1 1 Product1
      1 Category1 2 Product2
      2 Category2 4 Product4
      2 Category2 5 Product5
      3 Category3 6 Product6

      In the Category-result ResultMap, groupBy="Id" tells the mapper to only create a single Category object for every row in the query result that shares the same Id (mapped from CAT_ID).
      Therefore in the example, even though the query returned 5 rows, only 3 Cateogry objects will be created since there are only three distinct CAT_IDs in the query result.

      Attachments

        Activity

          People

            Unassigned Unassigned
            mnbob70 Bob Hanson
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: