Gilles, I've looked at the code for the new <discriminator> node for
<resultMap>s and I can't get my head around it. I believe the idea came
from the Hibernate people:

http://www.hibernate.org/hib_docs/reference/en/html/inheritance.html
http://groups-beta.google.com/groups?q=Hibernate+discriminator

>From reading those articles, is it correct to say that I use a
discriminator to decide how sub-objects are populated?

Is a <discriminator> used in conjunction with <subMap> nodes? This url:

http://tinyurl.com/c9vk8
http://svn.apache.org/repos/asf/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Document.xml

has the following text:

<resultMap id="document" class="Document">
 <result property="Id" column="Document_ID"/>
 <result property="Title" column="Document_Title"/>
 <discriminator column="Document_Type"  /> 
 <subMap value="Book" resultMapping="book" />
 <subMap value="Newspaper" resultMapping="newspaper" />
</resultMap>

Can I replace that with this:

<resultMap id="document" class="Document">
 <result property="Id" column="Document_ID"/>
 <result property="Title" column="Document_Title"/>
 <discriminator column="Document_Type"  /> 
</resultMap>

Do I need to use <subMap> nodes when I use a <discriminator> node?

If they are related, shouldn't I access it in a parent child relation:

 <!-- ??? -->
 <discriminator column="Document_Type"> 
  <subMap value="Book" resultMapping="book" />
  <subMap value="Newspaper" resultMapping="newspaper" />
 </discriminator>

I know that's not valid according to the schema:

http://tinyurl.com/cufl2
http://svn.apache.org/repos/asf/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMap.xsd

but I don't understand why.

Can anyone recommend an article or some better search terms for more
information.

Thanks,
Ron

Reply via email to