Class ResultMap

java.lang.Object
com.ibatis.sqlmap.engine.mapping.result.ResultMap
Direct Known Subclasses:
AutoResultMap

public class ResultMap extends Object
Basic implementation of ResultMap interface.
  • Field Details

    • delegate

      protected SqlMapExecutorDelegate delegate
      The delegate.
    • allowRemapping

      protected boolean allowRemapping
      The allow remapping.
    • NO_VALUE

      public static final Object NO_VALUE
      The Constant NO_VALUE.
  • Constructor Details

    • ResultMap

      public ResultMap(SqlMapExecutorDelegate delegate)
      Constructor to pass a SqlMapExecutorDelegate in.
      Parameters:
      delegate - - the SqlMapExecutorDelegate
  • Method Details

    • getDelegate

      public SqlMapExecutorDelegate getDelegate()
      Getter for the SqlMapExecutorDelegate.
      Returns:
      - the delegate
    • getId

      public String getId()
      Gets the id.
      Returns:
      the id
    • setId

      public void setId(String id)
      Setter for the ID.
      Parameters:
      id - - the new ID
    • getResultClass

      public Class getResultClass()
      Gets the result class.
      Returns:
      the result class
    • getUniqueKey

      public Object getUniqueKey(String keyPrefix, Object[] values)
      Gets the unique key.
      Parameters:
      keyPrefix - the key prefix
      values - the values
      Returns:
      the unique key
    • getUniqueKey

      public Object getUniqueKey(Object[] values)
      Gets the unique key.
      Parameters:
      values - the values
      Returns:
      the unique key
    • setResultClass

      public void setResultClass(Class resultClass)
      Setter for the result class (what the results will be mapped into).
      Parameters:
      resultClass - - the result class
    • getDataExchange

      public DataExchange getDataExchange()
      Getter for the DataExchange object to be used.
      Returns:
      - the DataExchange object
    • setDataExchange

      public void setDataExchange(DataExchange dataExchange)
      Setter for the DataExchange object to be used.
      Parameters:
      dataExchange - - the new DataExchange object
    • getXmlName

      public String getXmlName()
      Getter (used by DomDataExchange) for the xml name of the results.
      Returns:
      - the name
    • setXmlName

      public void setXmlName(String xmlName)
      Setter (used by the SqlMapBuilder) for the xml name of the results.
      Parameters:
      xmlName - - the name
    • getResource

      public String getResource()
      Getter for the resource (used to report errors).
      Returns:
      - the resource
    • setResource

      public void setResource(String resource)
      Setter for the resource (used by the SqlMapBuilder).
      Parameters:
      resource - - the resource name
    • addGroupByProperty

      public void addGroupByProperty(String name)
      Adds the group by property.
      Parameters:
      name - the name
    • hasGroupBy

      public boolean hasGroupBy()
      Checks for group by.
      Returns:
      true, if successful
    • groupByProps

      public Iterator groupByProps()
      Group by props.
      Returns:
      the iterator
    • addNestedResultMappings

      public void addNestedResultMappings(ResultMapping mapping)
      Adds the nested result mappings.
      Parameters:
      mapping - the mapping
    • getNestedResultMappings

      public List getNestedResultMappings()
      Gets the nested result mappings.
      Returns:
      the nested result mappings
    • getResultMappings

      public ResultMapping[] getResultMappings()
      Gets the result mappings.
      Returns:
      the result mappings
    • setDiscriminator

      public void setDiscriminator(Discriminator discriminator)
      Sets the discriminator.
      Parameters:
      discriminator - the new discriminator
    • getDiscriminator

      public Discriminator getDiscriminator()
      Gets the discriminator.
      Returns:
      the discriminator
    • resolveSubMap

      public ResultMap resolveSubMap(StatementScope statementScope, ResultSet rs) throws SQLException
      Resolve sub map.
      Parameters:
      statementScope - the statement scope
      rs - the rs
      Returns:
      the result map
      Throws:
      SQLException - the SQL exception
    • setResultMappingList

      public void setResultMappingList(List resultMappingList)
      Setter for a list of the individual ResultMapping objects.
      Parameters:
      resultMappingList - - the list
    • getResultCount

      public int getResultCount()
      Getter for the number of ResultMapping objects.
      Returns:
      - the count
    • getResults

      public Object[] getResults(StatementScope statementScope, ResultSet rs) throws SQLException
      Read a row from a resultset and map results to an array.
      Parameters:
      statementScope - scope of the request
      rs - ResultSet to read from
      Returns:
      row read as an array of column values.
      Throws:
      SQLException - the SQL exception
    • setResultObjectValues

      public Object setResultObjectValues(StatementScope statementScope, Object resultObject, Object[] values)
      Sets the result object values.
      Parameters:
      statementScope - the statement scope
      resultObject - the result object
      values - the values
      Returns:
      the object
    • setNestedResultMappingValue

      protected void setNestedResultMappingValue(ResultMapping mapping, StatementScope statementScope, Object resultObject, Object[] values)
      Some changes in this method for IBATIS-225:
      • We no longer require the nested property to be a collection. This will allow reuses of resultMaps on 1:1 relationships
      • If the nested property is not a collection, then it will be created/replaced by the values generated from the current row.
      Parameters:
      mapping - the mapping
      statementScope - the statement scope
      resultObject - the result object
      values - the values
    • getNestedSelectMappingValue

      protected Object getNestedSelectMappingValue(StatementScope statementScope, ResultSet rs, ResultMapping mapping, Class targetType) throws SQLException
      Gets the nested select mapping value.
      Parameters:
      statementScope - the statement scope
      rs - the rs
      mapping - the mapping
      targetType - the target type
      Returns:
      the nested select mapping value
      Throws:
      SQLException - the SQL exception
    • getPrimitiveResultMappingValue

      protected Object getPrimitiveResultMappingValue(ResultSet rs, ResultMapping mapping) throws SQLException
      Gets the primitive result mapping value.
      Parameters:
      rs - the rs
      mapping - the mapping
      Returns:
      the primitive result mapping value
      Throws:
      SQLException - the SQL exception
    • doNullMapping

      protected Object doNullMapping(Object value, ResultMapping mapping) throws SqlMapException
      Do null mapping.
      Parameters:
      value - the value
      mapping - the mapping
      Returns:
      the object
      Throws:
      SqlMapException - the sql map exception