Thanks Paul,

I think though it's not a quite straightforward solution it must work for me.

Regards
Ilya

MCCORMICK, Paul wrote:
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.

E,g.
<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"/>
    </discriminator>
</resultMap>


Paul



-----Original Message-----
From: Ilya Boyandin [mailto:[EMAIL PROTECTED]

Sent: Monday, 3 September 2007 4:39 PM
To: [email protected]
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"/>
    </discriminator>
</resultMap>

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

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

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

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
Ilya



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

Reply via email to