ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jakub Scheibe" <jakub.sche...@gmail.com>
Subject Re: Select problem...
Date Thu, 15 Mar 2007 14:14:09 GMT
Ok here are my simplified classes

    public class Class1
    {

        couple of props and methods

        public Class2 Class2
        {
            get
            {
                return _Class2;
            }
            set
            {
                _Class2 = value;
            }
        }

    public class Class2
    {
        private Class3 Class3;

        public Class3
        {
            get
            {
                return _Class3
            }
            set
            {
                _Class3 = value;
            }
        }

and Class3 with some props and methods.

Do I really need to declare any prop ? Test was just an example of
any property that i have in the classes.

On 15/03/07, Bob Hanson <mnbob70@gmail.com> wrote:
>
> Based on your example, class1 contains a public instance of class2, not
> class3.
>
> You also don't show any property named Test on your classes. If class1
> has a property named Test which is declared as "public class2 Test",
> then your result map for class1 needs to select a class2 object
> instead of a class3 object.
>
> On 3/15/07, Jakub Scheibe <jakub.scheibe@gmail.com> wrote:
> > Hi,
> >
> > I have 3 classes:
> >
> > class1
> > {
> >    public string id;
> >    public class2 _class2;
> > }
> >
> > class2
> > {
> >   public class3 _class3;
> > }
> >
> > class3
> > {
> >   public string test;
> > }
> >
> > The problem is when I'm trying to execute select command.
> > I have 2 sqlmap.xml file for class1 and class3.
> > f.e.
> >
> > class1.xml
> >
> >     <resultMap id="rmSelectClass1" class="Class1">
> >       <result property="Id" column="ID"/>
> >       <result property="Test" column="Test" select="SelectClass3"/>
> >     </resultMap>
> >
> >     <select id="Class1Select" resultMap="rmSelectClass1">
> >       select *
> >       from my_table
> >     </select>
> >
> > class3.xml
> >
> >     <resultMap id="rmSelectClass3" class="Class3">
> >       <result property="Test" column="Test"/>
> >     </resultMap>
> >
> >     <select id="SelectClass3" resultMap="rmClass3"">
> >         select Test
> >         from my_table2
> >     </select>
> >
> > When i'm runing my test i'm getting following error:
> > Unable to cast object of type 'Class3' to type 'Class2'
> >
> > Any help?
> >
>

Mime
View raw message