You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Sebastien Lucas <se...@gmail.com> on 2005/06/28 16:41:02 UTC

0-1 relationship with IBatis

Hi,

Another silly question from me, I read the tutorial and the
documentation and I haven't found an answer.

I have a table called Person and inside a field called
DriverLicenseType which is link to a table of DriverLicenseType :
DriverLicense (with a code and long text).
If DriverLicenseType is always filled then no problem I see how I have
to configure the sqlmap to make it work.

But here is the problem, DriverLicenseType can be null (the guy has no
driving license). How can I configure Ibatis to avoid to read
DriverLicense when the type is null ?

Thanks in advance.

Sébastien.

Re: 0-1 relationship with IBatis

Posted by Sebastien Lucas <se...@gmail.com>.
On 6/30/05, Sebastien Lucas <se...@gmail.com> wrote:
> On 6/28/05, Gilles Bayon <ib...@gmail.com> wrote:
> > The Java version can deal simply with this but not the .NET version (in a
> > future release).
> > A solution will be to use a select attribute
> > <result property="..." column="..." select=".." />
> > Another is tu use a discriminator element.
> 
> Hi Gilles,
> 
> If I use
> <result property="DriverLicense" column="DriverLicenseType"
> select="DriverLicenseSelect" />
> 
> I guess even when DriverLicenseType is null the select will still be
> made. So that's not what I want.
> 
> I read a little about discriminator but I'm not sure if testing a
> submap value for "" will be sufficient to catch null values.
> 
> I'll test that soon.
> 
> Thanks for your answer.
> 
> Sébastien
> 
> PS : Sorry Gilles it seems that I sent my first answer to you directly ;)
> 

Hi again,

Sorry for bugging you again, I made the test with a simple 
<result property="DriverLicense" column="DriverLicenseType"
> select="DriverLicenseSelect" />
as Gilles advised and it works perfectly.

Thanks.

Re: 0-1 relationship with IBatis

Posted by Sebastien Lucas <se...@gmail.com>.
On 6/28/05, Gilles Bayon <ib...@gmail.com> wrote:
> The Java version can deal simply with this but not the .NET version (in a
> future release). 
> A solution will be to use a select attribute 
> <result property="..." column="..." select=".." /> 
> Another is tu use a discriminator element. 

Hi Gilles,

If I use
<result property="DriverLicense" column="DriverLicenseType"
select="DriverLicenseSelect" />

I guess even when DriverLicenseType is null the select will still be
made. So that's not what I want.

I read a little about discriminator but I'm not sure if testing a
submap value for "" will be sufficient to catch null values.

I'll test that soon.

Thanks for your answer.

Sébastien

PS : Sorry Gilles it seems that I sent my first answer to you directly ;)

Re: 0-1 relationship with IBatis

Posted by Gilles Bayon <ib...@gmail.com>.
The Java version can deal simply with this but not the .NET version (in a 
future release).
A solution will be to use a select attribute
<result property="..." column="..." select=".." />
Another is tu use a discriminator element.