Nevermind, I solved it so far: used wrong column name - they should
definately give clearer error messages. Also tested the m-n relationship
which works fine. But now I get an InvalidCastException: "Specified cast is
not valid." without innerexception. 

This is the debug output before it goes wrong:

10/07/2006 16:54:25 [DEBUG] IBatisNet.DataMapper.SqlMapSession - Close
Connection "22584602" to "Oracle, Microsoft provider V1.0.5000.0".
10/07/2006 16:57:51 [DEBUG] IBatisNet.DataMapper.SqlMapSession - Open
Connection "1669504" to "Oracle, Microsoft provider V1.0.5000.0".
10/07/2006 16:57:51 [DEBUG]
IBatisNet.DataMapper.Commands.DefaultPreparedCommand - Statement Id:
[SelectAllPersoon] PreparedStatement : [select p.*, g.*        from PERSOON
p, GEMEENTE g        where p.CD_PERS_PST = g.CD_GEM_PST(+)        and
p.CD_PERS_LAND = g.Cd_Gem_Land(+)        and p.CD_PERS_TAAL =
g.CD_GEM_TAAL(+)]
A first chance exception of type 'System.InvalidCastException' occurred in
IBatisNet.DataMapper.dll
System.Transactions Critical: 0 : <TraceRecord
xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord";
Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled
exception</Description><AppDomain>IbatisTest.vshost.exe</AppDomain><Exception><ExceptionType>System.InvalidCastException,
mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Specified cast is
not valid.</Message><StackTrace>   at
System.Data.OracleClient.OracleColumn.GetString(NativeBuffer_RowBuffer
buffer)
   at System.Data.OracleClient.OracleDataReader.GetString(Int32 i)
...


The relevant xml code:

    <select id="SelectAllPersoon" resultMap="SelectResult">
      select p.*, g.*
      from PERSOON p, GEMEENTE g
      where p.CD_PERS_PST = g.CD_GEM_PST(+)
      and p.CD_PERS_LAND = g.Cd_Gem_Land(+)
      and p.CD_PERS_TAAL = g.CD_GEM_TAAL(+)
    </select>

    <resultMap id="SelectResult" class="Persoon">
      ...
      <result property="Gemeente"
resultMapping="Gemeente.SelectGemeenteResult"/>
      ...
    </resultMap>

    <resultMap id="SelectGemeenteResult" class="Gemeente">
      <result property="Pst" column="CD_GEM_PST"/>
      <result property="Land" column="CD_GEM_LAND"/>
      <result property="Taal" column="CD_GEM_TAAL"/>
      <result property="Naam" column="ST_GEM_NAAM"/>
    </resultMap>

The relevant C# code:

class Persoon: DatabankObject
{
                ...
                public Gemeente Gemeente
                {
                        get { return _gemeente; }
                        set { _gemeente = value; }
                }
                ...
}

        class Gemeente: DatabankObject
        {
                private string _pst;
                ...

                public string Pst
                {
                        get { return _pst; }
                        set { _pst = value; }
                }

                ...
        }
-- 
View this message in context: 
http://www.nabble.com/indexoutofrangeexception-using-resultMapping---tf1918301.html#a5253283
Sent from the iBATIS - User - Cs forum at Nabble.com.

Reply via email to