On Friday 14 Oct 2005 23:01, Alan Chandler wrote:
...
> >
> > I think the manual implies this - is it correct?
> >
> > <resultMap id="family-list" class="family"
> >     groupBy="a_key" >
> >     <result property=a_key column="{marriage.spouse.id = sid, marriage.m_no
> > =m_no}" />
> >
> > ... (ignoring mail wordwrap issues)
>
> This doesn't work
>
> I get a Runtime exception
>
> Caused by: com.ibatis.common.beans.ProbeException: There is no WRITEABLE
> property named 'a_key' in class
> 'uk.org.chandlerfamily.sqlmap.famtree.Family'

So I made a writeable property,

but I now getting this message

Caused by: com.ibatis.sqlmap.client.SqlMapException: No type handler could be 
found to map the property 'marriage.mkey' to the column 
'{spouseid=sid,mno=m_no}'. One or both of the types, or the combination of 
types is not supported.

So HOW DO I make this work?

My Result map fragment is 

        <resultMap id="family-list" class="family"
                groupBy="marriage.mkey" >
                <result property="marriage.mkey" 
column="{spouseid=sid,mno=m_no}"/>
,,,

And so as to incorprate marriage.mkey as the property I created a class MKey 
(all the private variables have an appropriate getters and setters)

public class Mkey {
        private int spouseid;
        private short mno;
...
}

The Family class refered to in the result map is as follows (together with the 
Marriage class which is the type of one of the variables - and again there 
are getters and setters for the private variables AND a special getter and 
setter for a psuedo mkey variable)

public class Family  { 
        private Marriage marriage; 
...
}

public class Marriage { 
        private PersonSummary spouse; 
        private short m_no; 
...
        public void setMkey (Mkey mkey) { 
                spouse.setId(mkey.getSpouseid()); 
                m_no=mkey.getMno(); 
        } 
         
        public Mkey getMkey() { 
                return new Mkey(spouse.getId(),m_no); 
        } 
...
}

-- 
Alan Chandler
http://www.chandlerfamily.org.uk
Open Source. It's the difference between trust and antitrust.

Reply via email to