Hi, I'm trying to get my feet wet using IBatis. I'm attempting to
follow the examples I'm seeing in the documentation but I must have my
mapping setup wrong. I'm simply trying to load a list of Benefits under
a parent object by passing a parameter into the select statement.
However, I keep getting the error below. Any advice
Here is my map
<?xml version="1.0" encoding="utf-8" ?>
<sqlMap
namespace="PlanPopulation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://ibatis.apache.org/mapping" >
<alias>
<typeAlias alias="PlanPopulation"
type="Trion.Entities.PlanPopulation, Trion.Entities" />
<typeAlias alias="Benefit"
type="Trion.Entities.Benefit, Trion.Entities"/>
</alias>
<resultMaps>
<resultMap id="SelectResult"
class="PlanPopulation">
<result property="CompanyID"
column="COMPANY_ID" />
<result property="PlanYearID"
column="PLAN_YEAR_ID" />
<result property="StartDate"
column="MASTER_PLAN_START_DATE" />
<result property="EndDate"
column="MASTER_PLAN_END_DATE"/>
<result property="Benefits"
column="COMPANY_ID=COID" select="SelectBenefits" />
</resultMap>
<resultMap id="BenefitResult" class="Benefit">
<result property="PlanType"
column="PP_PLAN_TYPE"/>
<result property="Description"
column="PLAN_DESCRIPTION"/>
</resultMap>
</resultMaps>
<statements>
<select id="Select" parameterClass="int"
resultMap="SelectResult">
select
COMPANY_ID,
PLAN_YEAR_ID,
MASTER_PLAN_START_DATE,
MASTER_PLAN_END_DATE
FROM EOL_MASTER_PLAN
WHERE COMPANY_ID = #CompanyID#
AND PLAN_YEAR_ID = #PlanYearID#
</select>
<select id="SelectBenefits"
resultMap="BenefitResult" >
Select PP_PLAN_TYPE,
PLAN_DESCRIPTION FROM EOL_PLAN_TYPE
WHERE COMPANY_ID = #COID#
</select>
</statements>
</sqlMap>
And the error
TestCase 'IBatisUnitTests.GeneralTests.GetPlanPopulation' failed:
System.IndexOutOfRangeException : COID
at
System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName)
at System.Data.SqlClient.SqlDataReader.GetOrdinal(String
name)
at
IBatisNet.DataMapper.Commands.DataReaderDecorator.System.Data.IDataRecor
d.GetOrdinal(String name)
at
IBatisNet.DataMapper.MappedStatements.PropertyStrategy.SelectStrategy.Se
t(RequestScope request, IResultMap resultMap, ResultProperty mapping,
Object& target, IDataReader reader, Object selectKeys)
at
IBatisNet.DataMapper.MappedStatements.ResultStrategy.ResultMapStrategy.P
rocess(RequestScope request, IDataReader& reader, Object resultObject)
at
IBatisNet.DataMapper.MappedStatements.ResultStrategy.MapStrategy.Process
(RequestScope request, IDataReader& reader, Object resultObject)
at
IBatisNet.DataMapper.MappedStatements.MappedStatement.RunQueryForObject[
T](RequestScope request, ISqlMapSession session, Object parameterObject,
T resultObject)
at
IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForObj
ect[T](ISqlMapSession session, Object parameterObject, T resultObject)
at
IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForObj
ect[T](ISqlMapSession session, Object parameterObject)
at IBatisNet.DataMapper.SqlMapper.QueryForObject[T](String
statementName, Object parameterObject)
Joseph Benckert
Trion(tm)
2300 Renaissance Blvd.
King of Prussia, PA 19406
P: 610-945-1166
F: 610-945-1166
E: [EMAIL PROTECTED]
W: www.trion.com <http://www.trion.com/>
Confidentiality Notice: This e-mail transmission may contain confidential or
legally privileged information that is intended only for the individual or
entity named in the e-mail address.
If you are not the intended recipient, you are hereby notified that any
disclosure, copying, distribution, or reliance upon the contents of this e-mail
is strictly prohibited. If you have received this e-mail transmission in error,
please reply to the sender, so that arrangements can be made for proper
delivery, and then please delete the message from your inbox.