ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "MCCORMICK, Paul" <Paul.McCORM...@doir.wa.gov.au>
Subject RE: JIRA 225 and discriminator tag.
Date Wed, 02 Aug 2006 03:16:51 GMT
No problem,  I'll provide the unit test.


From: Jeff Butler [mailto:jeffgbutler@gmail.com] 
Sent: Wednesday, 2 August 2006 11:09 AM
To: user-java@ibatis.apache.org
Subject: Re: JIRA 225 and discriminator tag.

I'll take a look at this.  If you can provide a reproducable test case,
it would be good to add the test case to the JIRA ticket.
Jeff Butler

On 8/1/06, MCCORMICK, Paul <Paul.McCORMICK@doir.wa.gov.au> wrote: 

	I've downloaded the latest ibatis code from SVN last week as I
needed the following feature:

	I have encountered a problem.  The reused result map ignores the
discriminator tag.   I've attached some code below.  The
legDiscriminatorTestFails query fails.   The query should return a
DisplayTenement object containing a single Legislation object.  The
query legDiscriminatorTestWorks works.   This returns a single
Legislation object. Both queries use the same args and return the same
db results.  In the query that fails  the discriminator tag does not
find a match for any sub Maps so it defaults to using the Legislation
class which is abstract.   Am I doing something wrong? 

	Here are the classes: 
	public class DisplayTenement {    
	    private Integer id; 
	    private Legislation legislation;    

	public abstract class Legislation { 
	    private Integer tenementId;     

	public class SpecialProspectingLegislation82 extends Legislation


	<resultMap id ="tenementLegislationRM" class= "Legislation" > 
	        <result property="id" column="LEGISLATION_ID"/> 
	        <result property ="tenementId" column= "TENEMENT_ID"/> 
	        <result property="effectiveRange" column="START_STMP"/> 
	        <result property ="versionId" column=
	        < discriminator column="LEGISLATION_CODE"
javaType="java.lang.String" > 
	                <subMap value ="AMLS60" resultMap=
	                < subMap value="CWOS80"
	                <subMap value ="CWOS94" resultMap=
	                < subMap value="EL05NM"
	                ..... about 20 more subMaps ...... 
	        </ discriminator> 
	</resultMap > 

	<!-- This is the common query used for testing --> 
	< sql id="legDiscriminatorTestSQL" > 

	        WHERE leg.LEGISLATION_ID = #value# 

	<!-- Re using the result map tenementLegislationRM test --> 
	< resultMap id="oneToOneTestRM"
class="emits.domain.tenement.DisplayTenement" > 
	        <result property ="id" column= "TENEMENT_ID"/> 
	        <result property="legislation"
resultMap="Legislation.tenementLegislationRM" /> 

	<!-- Returns a single DisplayTenement containing a Legislation
	     This query fails. --> 
	<select id="legDiscriminatorTestFails"
resultMap="oneToOneTestRM" > 
	        <include refid ="legDiscriminatorTestSQL"/> 
	</ select> 

	<!-- Returnes a single Legislation object --> 
	<select id ="legDiscriminatorTestWorks" resultMap=
"Legislation.tenementLegislationRM" > 
	        <include refid= "legDiscriminatorTestSQL"/> 
	</ select> 

"DISCLAIMER: This email, including any attachments, is intended only for
use by the addressee(s) and may contain confidential and/or personal
information and may also be the subject of legal privilege. If you are
not the intended recipient, you must not disclose or use the information
contained in it. In this case, please let me know by return email,
delete the message permanently from your system and destroy any copies. 

Before you take any action based upon advice and/or information
contained in this email you should carefully consider the advice and
information and consider obtaining relevant independent advice.

View raw message