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: 

	Hi, 
	I've downloaded the latest ibatis code from SVN last week as I
needed the following feature:
http://issues.apache.org/jira/browse/IBATIS-225
<http://issues.apache.org/jira/browse/IBATIS-225>  

	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=
"LEGISLATION_VERSION_ID"/> 
	        < discriminator column="LEGISLATION_CODE"
javaType="java.lang.String" > 
	                <subMap value ="AMLS60" resultMap=
"Legislation.AMLS60"/> 
	                < subMap value="CWOS80"
resultMap="Legislation.CWOS80"/> 
	                <subMap value ="CWOS94" resultMap=
"Legislation.CWOS94"/> 
	                < subMap value="EL05NM"
resultMap="Legislation.EL05NM"/> 
	                ..... about 20 more subMaps ...... 
	        </ discriminator> 
	</resultMap > 

	<!-- This is the common query used for testing --> 
	< sql id="legDiscriminatorTestSQL" > 
	        SELECT leg.LEGISLATION_ID, leg.TENEMENT_ID,
leg.LEGISLATION_CODE, leg.START_STMP, leg.END_STMP, leg.VERSION_ID AS
LEGISLATION_VERSION_ID

	        FROM EM_TENEMENT_LEGISLATION_TB leg 
	        WHERE leg.LEGISLATION_ID = #value# 
	</sql> 

	<!-- 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" /> 
	</resultMap> 

	<!-- Returns a single DisplayTenement containing a Legislation
object 
	     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.
	



Mime
View raw message