I am trying to use an embedded object in a result map, but I get the following error:
IBatisNet.Common.Exceptions.ConfigurationException:
- The error occurred while loading SqlMap .
- initialize result property :Message.To
- The error occurred in <sqlMap url="" />.
- Check the Email.EmailResult. ---> IBatisNet.Common.Exceptions.ConfigurationException: Could not configure ResultMap. ResultMap named "EmailResult" not found, failed.
Cause: There is no Set property named 'Message.To' in class 'EmailMessage'
at IBatisNet.DataMapper.Configuration.ResultMapping.ResultMap.Initialize(ConfigurationScope configScope)
Does the .NET version of 1.2 DataMapper support what the docs say regarding this?
This is from the dev guide for iBatis....
The solution is to use a join and nested property mappings instead of a separate select statement. Here’s an
example using the same situation as above (Products and Categories):
Developer Guide iBATIS SQL Maps 2
http://www.ibatis.com by Clinton Begin
26
<resultMap id=”get-product-result” class=”com.ibatis.example.Product”>
<result property=”id” column=”PRD_ID”/>
<result property=”description” column=”PRD_DESCRIPTION”/>
<result property=”category.id” column=”CAT_ID” />
<result property=”category.description” column=”CAT_DESCRIPTION” />
</resultMap>
This is my result map definition:
<resultMaps>
<resultMap id="EmailResult" class="EmailMessage">
<result property="Id" column="ID"/>
<result property="Message.To" column="TO"/>
</resultMap>
</resultMaps>
This is my EmailMessage Object:
public class EmailMessage : BaseDomainEntity, IMessage {
private System.Web.Mail.MailMessage _message = new System.Web.Mail.MailMessageMailMessage();
public System.Web.Mail.MailMessage Message {
get { return _message; }
set { _message = value; }
}
}