"Composite Keys or Multiple Complex Parameters Properties" - incorrect parsing
of column properties
---------------------------------------------------------------------------------------------------
Key: IBATISNET-166
URL: http://issues.apache.org/jira/browse/IBATISNET-166
Project: iBatis for .NET
Type: Bug
Components: DataMapper
Versions: DataMapper 1.3
Environment: Microsoft Windows Server 2003, DotNetFramework 1.1
Reporter: cristian manea
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
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira