I seem to be having a lot of trouble sending mail to the list these last
two days. If you see this more than once, I apologize. On my side, it
claims to be bounced due to an unknown user or rejected by a moderator
or it tells me I am not subscribed (at least two of which I don't
believe to be true).
Tony
-----
Okay, I have a problem that I just don't understand. As always, any
insight or help is *greatly* appreciated.
The issue is directly related to result map properties or constructor
arguments that are classes (child objects). If I get a list of objects
with no child objects defined in the results, it works fine. If I get a
list of objects with a child object defined, but I limit the records
returned to those which have null values in the FK field, it works fine.
However, if my list of returned records contains even one record with an
actual FK value in the column defined in the result map as a child
object, I get the following error:
System.NotImplementedException was unhandled
Message="The property 'GroupByPropertyNames' is not implemented."
Source="IBatisNet.DataMapper"
This error is very misleading. I have spent some time combing through
the iBATIS code and I think I see what the problem is, but I don't
understand what's causing it.
There are two primary symptoms here, of which one or both may be the
root cause (or may point someone with more in-depth iBATIS knowledge to
the root cause).
My RequestScope._statement.ResultsMap collection contains 2 result maps.
The first one is the one I have defined in my SQL map file (see below).
The second one is of the type
IBatisNet.DataMapper.Configuration.ResultMapping.AutoResultMap, which
does not implement the GroupByPropertyNames property (hence the error
above). I didn't create this second result map and I don't know why it
is being added to the collection. I have included the pertinent SQL map
stuff below, in case someone can spot if/where I am including or
omitting attributes/tags that is causing this to happen.
Second, when SelectStrategy.GetValue() makes its internal call to
SelectObjectStrategy.GetValue() the IDataReader instance is converted to
an InMemoryDataReader(). During the course of this conversion (in the
constructor), there is a call made to the
DataReaderDecorator.NextResult() function. This causes the next result
map in the RequestScope._statement.ResultsMap to become the current
result map. Since this result map is of type AutoResultMap, it throws
the above exception.
It seems to me (with very limited insight and knowledge thus far) that I
need to find a way to prevent this AutoResultMap from being added to my
statement and/or the InMemoryDataReader() constructor needs to be
updated to put the current result map pointer back where it found it,
instead of incrementing it unnecessarily.
Can anyone please provide any insight here? Am I on to something? If
so, what? If this is a problem with my sql maps, can you pointout where
I made the mistake? I am at my wit's end here. :-/
Thank you very much for your help!
Tony
-------
C# Call
-------
TList<User> u = (TList<User>)_mapper.QueryForList<User>("GetAllUser",
null);
----------
User Types
----------
<alias>
<typeAlias alias="UserClass"
type="Entities.User, Entities" />
<typeAlias alias="UserList"
type="Entities.TList`1[Entities.User], Entities" />
</alias>
-----------
User Select
-----------
<select id="GetAllUser" resultMap="UserResult"
resultClass="UserClass" listClass="UserList">
<![CDATA[
SELECT USER_ID,
FIRST_NAME,
LAST_NAME,
DEPARTMENT_ID,
FACILITY_ID,
EMP_ID
FROM USER_T
]]>
</select>
---------------
User Result Map
---------------
<resultMap id="UserResult" class="UserClass">
<constructor>
<argument argumentName="userId" column="USER_ID" />
<argument argumentName="firstName" column="FIRST_NAME" />
<argument argumentName="lastName" column="LAST_NAME" />
<argument argumentName="departmentId" column="DEPARTMENT_ID"
/>
<argument argumentName="facility" column="FACILITY_ID"
select="GetFacilityByPrimaryKey" />
<argument argumentName="empId" column="EMP_ID" />
</constructor>
</resultMap>
--------------
Facility Types
--------------
<alias>
<typeAlias alias="FacilityClass"
type="Entities.Facility, Entities" />
<typeAlias alias="FacilityList"
type="Entities.TList`1[Entities.Facility], Entities" />
</alias>
-------------------
Facility Result Map
-------------------
<resultMap id="FacilityResult" class="FacilityClass">
<constructor>
<argument argumentName="facilityId" column="FACILITY_ID" />
<argument argumentName="name" column="NAME" />
<argument argumentName="description" column="DESCRIPTION" />
</constructor>
</resultMap>
----------------------
Facility Parameter Map
----------------------
<parameterMap id="FacilityPkParams">
<parameter property="FacilityId" column="FACILITY_ID" />
</parameterMap>
---------------
Facility Select
---------------
<select id="GetFacilityByPrimaryKey" parameterMap="FacilityPkParams"
resultMap="FacilityResult" resultClass="FacilityClass"
listClass="FacilityList">
<![CDATA[
SELECT FACILITY_ID,
NAME,
DESCRIPTION
FROM FACILITY_T
WHERE FACILITY_ID = ?
]]>
</select>