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: Using discriminator with an interface
Date Mon, 03 Sep 2007 09:21:14 GMT

If the sub classes have a common setter method then its possible the use the that setter as
the required single result in the result map.  As you interface will not have setters you'll
have to use any one of the sub classes (BlackSomething or WhiteSomething)  as the "class"
attribute in the main result map.   The calling java code can do the cast to Isomething interface.

<resultMap id="somethingResult" class="BlackSomething">
    <result property="id" column="ID"/>
    <discriminator column="type" javaType="string">
        <subMap value="black" resultMap="blackSomethingResult"/>
        <subMap value="white" resultMap="whiteSomethingResult"/>


-----Original Message-----
From: Ilya Boyandin [mailto:Ilya.Boyandin@fh-joanneum.at]
Sent: Monday, 3 September 2007 4:39 PM
To: user-java@ibatis.apache.org
Subject: Using discriminator with an interface

Hello all,

is that possible to use discriminator with an interface without setters?

I have something like this in my mappings:

<resultMap id="somethingResult" class="ISomething">
    <discriminator column="type" javaType="string">
        <subMap value="black" resultMap="blackSomethingResult"/>
        <subMap value="white" resultMap="whiteSomethingResult"/>

<resultMap id="blackSomethingResult" class="BlackSomething">

<resultMap id="whiteSomethingResult" class="WhiteSomething">

<select id="loadSomething" resultMap="somethingResult">

And I always get this RuntimeException: "resultMap Something.somethingResult must have at
least one result mapping". But somethingResult can't have any mappings because ISomething
is an interface without any setters.

Am I doing something wrong or is there any other way to accomplish this?

Thanks in advance

FH JOANNEUM Gesellschaft mbH
Rechtsform/Legal form: GmbH
Firmenbuchgericht/Court of registry: Landesgericht für ZRS Graz Firmenbuchnummer/Company
registration: FN 125888 f
DVR: 0813559
UID-Nr.: ATU 42361001

"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

View raw message