ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher.Mathru...@sybase.com
Subject RE: discriminator and submap
Date Mon, 06 Nov 2006 18:30:28 GMT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns:v = "urn:schemas-microsoft-com:vml" xmlns:o = 
"urn:schemas-microsoft-com:office:office" xmlns:w = 
"urn:schemas-microsoft-com:office:word"><HEAD>
<META urn:content-classes:message Content-class: 
boundary="----_=_NextPart_001_01C70005.43630DB0" alternative; multipart 
Content-Type:>
<META http-equiv=Content-Type content="text/html; charset=us-ascii" 
Content-Type: ------_="_NextPart_001_01C70005.43630DB0" html; text 
quoted-printable Content-Transfer-Encoding:>
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<BODY lang=EN-US vLink=purple link=blue>
<DIV dir=ltr align=left><SPAN class=532322918-06112006><FONT color=#0000ff

size=2>This worked like a charm. Thanks for the suggestion. I hadn't really 
thought of doing this but it makes perfect sense and it's extremely 
easy.</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> "Niels Beekman" &lt;n.beekman@wis.nl&gt;

[mailto:"Niels Beekman" &lt;n.beekman@wis.nl&gt;] <BR><B>Sent:</B>
Saturday, 
November 04, 2006 3:35 AM<BR><B>To:</B> 
&lt;user-java@ibatis.apache.org&gt;<BR><B>Subject:</B> RE: discriminator
and 
submap<BR></FONT><BR></DIV>
<DIV></DIV>
<META content="Microsoft Word 11 (filtered medium)" name=Generator><!--[if !mso]>
<STYLE>v\:* {
	BEHAVIOR: url(#default#VML)
}
o\:* {
	BEHAVIOR: url(#default#VML)
}
w\:* {
	BEHAVIOR: url(#default#VML)
}
.shape {
	BEHAVIOR: url(#default#VML)
}
</STYLE>
<![endif]-->
<STYLE>@font-face {
	font-family: Tahoma;
}
@page Section1 {size: 612.0pt 792.0pt; margin: 72.0pt 90.0pt 72.0pt 90.0pt; }
P.MsoNormal {
	FONT-SIZE: 12pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"
}
LI.MsoNormal {
	FONT-SIZE: 12pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"
}
DIV.MsoNormal {
	FONT-SIZE: 12pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"
}
A:link {
	COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlink {
	COLOR: blue; TEXT-DECORATION: underline
}
A:visited {
	COLOR: purple; TEXT-DECORATION: underline
}
SPAN.MsoHyperlinkFollowed {
	COLOR: purple; TEXT-DECORATION: underline
}
SPAN.EmailStyle17 {
	COLOR: navy; FONT-FAMILY: Arial; mso-style-type: personal-reply
}
DIV.Section1 {
	page: Section1
}
</STYLE>

<DIV class=Section1>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">If only if/else 
behaviour is required, why not create an additional column? Something 
like:<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p>&nbsp;</o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">SELECT *, CASE WHEN 
part_no IS NULL THEN 0 ELSE 1 END AS hasPartNo<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">FROM 
yourTable<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p>&nbsp;</o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">&nbsp;&nbsp;&nbsp;

&lt;discriminator column="hasPartNo" javaType="java.lang.Boolean" 
jdbcType="BIT"&gt;<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&lt;subMap value="1" resultMap="SupportItemResult_withPart" 
/&gt;<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&lt;subMap value="0" resultMap="SupportItemResult_withoutPart" 
/&gt;<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">&nbsp;&nbsp;&nbsp;

&lt;/discriminator&gt;<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p>&nbsp;</o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Niels<o:p></o:p></SPAN></FONT></P>
<DIV>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><FONT 
face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt">
<HR tabIndex=-1 align=center width="100%" SIZE=2>
</SPAN></FONT></DIV>
<P class=MsoNormal><B><FONT face=Tahoma size=2><SPAN 
style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: Tahoma">From:</SPAN></FONT></B><FONT

face=Tahoma size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"> 
Christopher.Mathrusse@sybase.com [mailto:Christopher.Mathrusse@sybase.com] 
<BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> zaterdag
4 november 2006 
1:42<BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> 
user-java@ibatis.apache.org<BR><B><SPAN 
style="FONT-WEIGHT: bold">Subject:</SPAN></B> RE: discriminator and 
submap</SPAN></FONT><o:p></o:p></P></DIV>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN 
style="FONT-SIZE: 12pt"><o:p>&nbsp;</o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" color=blue size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: blue">Well I did something similar but I still 
need to perform the 'else'.</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN 
style="FONT-SIZE: 12pt">&nbsp;<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" color=blue size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: blue">&nbsp;&nbsp;&nbsp; &lt;discriminator

column="part_no" javaType="java.lang.String" jdbcType="VARCHAR" 
nullValue="NULL"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;subMap
value="NULL" 
resultMap="SupportItemResult" /&gt;<BR>&nbsp;&nbsp;&nbsp; 
&lt;/discriminator&gt;</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN 
style="FONT-SIZE: 12pt">&nbsp;<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" color=blue size=2><SPAN 
style="FONT-SIZE: 10pt; COLOR: blue">My problem is that the above will apply the 
resultMap if the field part_no is null, but how do I apply a different resultMap 
if part_no is not null. I don't want to test for all possible values I only want 
a simple if/else basically.</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN 
style="FONT-SIZE: 12pt"><o:p>&nbsp;</o:p></SPAN></FONT></P>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><FONT 
face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt">
<HR tabIndex=-1 align=center width="100%" SIZE=2>
</SPAN></FONT></DIV>
<P class=MsoNormal style="MARGIN-BOTTOM: 12pt"><B><FONT face=Tahoma size=2><SPAN

style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: Tahoma">From:</SPAN></FONT></B><FONT

face=Tahoma size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"> 
larry.meadors@gmail.com [mailto:larry.meadors@gmail.com] <B><SPAN 
style="FONT-WEIGHT: bold">On Behalf Of </SPAN></B>"Larry Meadors" 
&lt;lmeadors@apache.org&gt;<BR><B><SPAN 
style="FONT-WEIGHT: bold">Sent:</SPAN></B> Friday, November 03, 2006 4:31 
PM<BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> 
user-java@ibatis.apache.org<BR><B><SPAN 
style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re: discriminator and 
submap</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal style="MARGIN-BOTTOM: 12pt"><FONT face="Times New Roman" 
size=3><SPAN style="FONT-SIZE: 12pt">I'd probably do something like NVL(field, 
'someMagicNullString') in <BR>the sql to make sure that it wasn't null. :-/ 
<BR><BR>Crude, but effective. <BR><BR>Larry <BR><BR><BR>On
11/3/06, 
Christopher.Mathrusse@sybase.com <BR><CHRISTOPHER.MATHRUSSE@SYBASE.COM>wrote:

<BR>&gt; <BR>&gt; <BR>&gt; Can I use the discriminator and sub
map to test for 
null values? Meaning if <BR>&gt; I define the discriminator for a field and I 
want to apply one result map if <BR>&gt; the field is null and another if it is

not, how do I define this? <BR>&gt; <BR>&gt; Thanks.... <BR>&gt;
<BR>&gt; Chris 
Mathrusse <BR>&gt; christopher.mathrusse@sybase.com <BR>&gt; (925) 236-5553

<BR>&gt; <o:p></o:p></SPAN></FONT></P></DIV></BODY></HTML>


Mime
View raw message