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

"Composite Keys or Multiple Complex Parameters Properties" - incorrect parsing of column properties

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • DataMapper 1.3
    • DataMapper 1.5
    • DataMapper
    • None
    • Microsoft Windows Server 2003, DotNetFramework 1.1

    Description

      The pdf documentation, Chapter 3, 3.5.13. Composite Keys or Multiple Complex Parameters Properties, says:

      "However, there is an alternate syntax that allows multiple columns to be passed to the related mapped statement. This comes in handy for situations where a composite key relationship exists, or even if you simply want to use a parameter of some name other than #value#. The alternate syntax for the column attribute is simply

      {param1=column1, param2=column2, ..., paramN=columnN}

      ."

      Instead I found there will be ALWAYS the error: "columnN}" while getting the value from the query; i have downloaded the source and I have identified the point where the error is made: the split of the column does not consider the fact the the } and { are part of the string.

      It will work only if we don't use the

      { and }

      when defining the column property in the sqlmap definition (but in this way, the specification for the column property is not followed). It olny works by not following the specifications .
      — column="idlabel=desc_fk,idlanguage=id_language" ----

      Source code in "MappedStatement.cs", project "IbatisNet.DataMapper" where I have identified the error:

      private void SetObjectProperty(RequestScope request, ResultMap resultMap, ResultProperty mapping, ref object target, IDataReader reader) ,
      ...............................
      if (paramString.IndexOf(',')>0 || paramString.IndexOf('=')>0) // composite parameters key
      {
      IDictionary keyMap = new Hashtable();
      keys = keyMap;
      // define which character is seperating fields
      char[] splitter =

      {'=',','}

      ;

      string[] paramTab = paramString.Split(splitter);
      if (paramTab.Length % 2 != 0)

      { throw new DataMapperException("Invalid composite key string format in '"+mapping.PropertyName+". It must be: property1=column1,property2=column2,..."); }

      IEnumerator enumerator = paramTab.GetEnumerator();
      while (!wasNull && enumerator.MoveNext())

      { string hashKey = ((string)enumerator.Current).Trim(); enumerator.MoveNext(); object hashValue = reader.GetValue( reader.GetOrdinal(((string)enumerator.Current).Trim()) ); keyMap.Add(hashKey, hashValue ); wasNull = (hashValue == DBNull.Value); }

      }
      ..................................

      Since i am not participating at the project, I cannot modify the source.

      Regards.

      Cristian Manea
      www.atypiqsoftware.ro

      Attachments

        Activity

          People

            gilles Gilles Bayon
            cristianmaneait cristian manea
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment