You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by OBender <os...@hotmail.com> on 2009/12/16 23:17:35 UTC

feature request for iBatis3

Hi All,

 

I guess this is a corner case but it is pretty important one for projects
with legacy data models.

Let say there is a table in DB that contains:

 

Column                Type

id                            int

s1                            string

s2                            string

s3                            string

 

 

Also let say it is modeled (historically) by two immutable objects:

 

public class ObjX 

{

                private final int id;

                private final String s1;

                private final ObjY objY;

 

                public    ObjX( int id, String s1, ObjY objY ) 

{

                                ...

                }

}

 

public class ObjY 

{

                private final String s2;

                private final String s3;

 

                public    ObjY( String s2, String s3 ) 

{

                                ...

                }

}

 

In this case there seems to be no way to build a result map for ObjX in
iBatis without changing ObjX code but what if we cannot change it?

 

It would be nice if we could use resultMap in <constructor>/<arg> element.

This way one could write something like:

 

<resultMap type="ObjX" id="ObjXResult">

        <constructor>

            <idArg column="id" javaType="_int" />

            <arg column="s1" javaType="String" />

            <arg javaType="ObjY" resultMap="ObjYResult"/>

        </constructor>

</resultMap>

 

<resultMap type="ObjY" id="ObjYResult">

        <constructor>

            <arg column="s2" javaType="String" />

            <arg column="s3" javaType="String" />

        </constructor>

</resultMap>

 

Comparable result could be achieved with TypeHandler but it will require
column names to be hardcoded in the TypeHandler implementation also will
require adding one TypeHandler per each such a case.

 

Thanks 


RE: feature request for iBatis3

Posted by OBender <os...@hotmail.com>.
Already there
https://issues.apache.org/jira/browse/IBATIS-717

Thanks a lot for looking in to it!

-----Original Message-----
From: Clinton Begin [mailto:clinton.begin@gmail.com] 
Sent: Wednesday, December 16, 2009 8:25 PM
To: user-java@ibatis.apache.org
Subject: Re: feature request for iBatis3

Can you create a jira ticket for this?  It might actually already
work, if we allow it in the DTD.

Clinton

On 2009-12-16, OBender <os...@hotmail.com> wrote:
> Hi All,
>
>
>
> I guess this is a corner case but it is pretty important one for projects
> with legacy data models.
>
> Let say there is a table in DB that contains:
>
>
>
> Column                Type
>
> id                            int
>
> s1                            string
>
> s2                            string
>
> s3                            string
>
>
>
>
>
> Also let say it is modeled (historically) by two immutable objects:
>
>
>
> public class ObjX
>
> {
>
>                 private final int id;
>
>                 private final String s1;
>
>                 private final ObjY objY;
>
>
>
>                 public    ObjX( int id, String s1, ObjY objY )
>
> {
>
>                                 ...
>
>                 }
>
> }
>
>
>
> public class ObjY
>
> {
>
>                 private final String s2;
>
>                 private final String s3;
>
>
>
>                 public    ObjY( String s2, String s3 )
>
> {
>
>                                 ...
>
>                 }
>
> }
>
>
>
> In this case there seems to be no way to build a result map for ObjX in
> iBatis without changing ObjX code but what if we cannot change it?
>
>
>
> It would be nice if we could use resultMap in <constructor>/<arg> element.
>
> This way one could write something like:
>
>
>
> <resultMap type="ObjX" id="ObjXResult">
>
>         <constructor>
>
>             <idArg column="id" javaType="_int" />
>
>             <arg column="s1" javaType="String" />
>
>             <arg javaType="ObjY" resultMap="ObjYResult"/>
>
>         </constructor>
>
> </resultMap>
>
>
>
> <resultMap type="ObjY" id="ObjYResult">
>
>         <constructor>
>
>             <arg column="s2" javaType="String" />
>
>             <arg column="s3" javaType="String" />
>
>         </constructor>
>
> </resultMap>
>
>
>
> Comparable result could be achieved with TypeHandler but it will require
> column names to be hardcoded in the TypeHandler implementation also will
> require adding one TypeHandler per each such a case.
>
>
>
> Thanks
>
>

-- 
Sent from my mobile device

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 9.0.716 / Virus Database: 270.14.101/2555 - Release Date: 12/14/09
14:40:00


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: feature request for iBatis3

Posted by Clinton Begin <cl...@gmail.com>.
Can you create a jira ticket for this?  It might actually already
work, if we allow it in the DTD.

Clinton

On 2009-12-16, OBender <os...@hotmail.com> wrote:
> Hi All,
>
>
>
> I guess this is a corner case but it is pretty important one for projects
> with legacy data models.
>
> Let say there is a table in DB that contains:
>
>
>
> Column                Type
>
> id                            int
>
> s1                            string
>
> s2                            string
>
> s3                            string
>
>
>
>
>
> Also let say it is modeled (historically) by two immutable objects:
>
>
>
> public class ObjX
>
> {
>
>                 private final int id;
>
>                 private final String s1;
>
>                 private final ObjY objY;
>
>
>
>                 public    ObjX( int id, String s1, ObjY objY )
>
> {
>
>                                 ...
>
>                 }
>
> }
>
>
>
> public class ObjY
>
> {
>
>                 private final String s2;
>
>                 private final String s3;
>
>
>
>                 public    ObjY( String s2, String s3 )
>
> {
>
>                                 ...
>
>                 }
>
> }
>
>
>
> In this case there seems to be no way to build a result map for ObjX in
> iBatis without changing ObjX code but what if we cannot change it?
>
>
>
> It would be nice if we could use resultMap in <constructor>/<arg> element.
>
> This way one could write something like:
>
>
>
> <resultMap type="ObjX" id="ObjXResult">
>
>         <constructor>
>
>             <idArg column="id" javaType="_int" />
>
>             <arg column="s1" javaType="String" />
>
>             <arg javaType="ObjY" resultMap="ObjYResult"/>
>
>         </constructor>
>
> </resultMap>
>
>
>
> <resultMap type="ObjY" id="ObjYResult">
>
>         <constructor>
>
>             <arg column="s2" javaType="String" />
>
>             <arg column="s3" javaType="String" />
>
>         </constructor>
>
> </resultMap>
>
>
>
> Comparable result could be achieved with TypeHandler but it will require
> column names to be hardcoded in the TypeHandler implementation also will
> require adding one TypeHandler per each such a case.
>
>
>
> Thanks
>
>

-- 
Sent from my mobile device

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org