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 Paul Sanders <te...@gmail.com> on 2007/04/11 16:55:22 UTC

Can You Map Column Indexes to Properties?

I have stored procedures that return Oracle REFCURSORs that I want to use
from iBATIS in Java. I've seen instructions on how to do this but I need to
be able to map column indexes to my bean properties rather than column
names. 

The reason for this is that our dba's, in their infinite wisdom, just
renamed all the columns in the latest version of our database to "meet
standards", but the changes are not being applied to the previous versions
that the application must still support. An "easy" fix is to have different
SQLMaps for each version but this is yucky. Better still would be to use
column indexes since the order has not changed, only the names.

So far I haven't seen any way to do this, but I am brand new to iBATIS -
anyone got any ideas?

Thanks

Paul
-- 
View this message in context: http://www.nabble.com/Can-You-Map-Column-Indexes-to-Properties--tf3559865.html#a9941267
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Can You Map Column Indexes to Properties?

Posted by Larry Meadors <lm...@apache.org>.
You can do that with a result map, yeah.

Larry


On 4/11/07, Paul Sanders <te...@gmail.com> wrote:
>
> I have stored procedures that return Oracle REFCURSORs that I want to use
> from iBATIS in Java. I've seen instructions on how to do this but I need to
> be able to map column indexes to my bean properties rather than column
> names.
>
> The reason for this is that our dba's, in their infinite wisdom, just
> renamed all the columns in the latest version of our database to "meet
> standards", but the changes are not being applied to the previous versions
> that the application must still support. An "easy" fix is to have different
> SQLMaps for each version but this is yucky. Better still would be to use
> column indexes since the order has not changed, only the names.
>
> So far I haven't seen any way to do this, but I am brand new to iBATIS -
> anyone got any ideas?
>
> Thanks
>
> Paul
> --
> View this message in context: http://www.nabble.com/Can-You-Map-Column-Indexes-to-Properties--tf3559865.html#a9941267
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>

Re: Can You Map Column Indexes to Properties?

Posted by Paul Sanders <te...@gmail.com>.


Jeff Butler-2 wrote:
> 
> You can do it with a result map like this:
> 
> <resultMap id="fredResult" class="somepackage.Fred">
>   <result property="id" columnIndex="1"/>
>   <result property="name" columnIndex="2"/>
> </resultMap>
> 
> Jeff Butler
> 

Ok, that looks perfect. Too bad I didn't see that in the docs I have, could
have saved some bandwidth in the tubes. Thanks Jeff for taking the time to
reply.
-- 
View this message in context: http://www.nabble.com/Can-You-Map-Column-Indexes-to-Properties--tf3559865.html#a9942088
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Can You Map Column Indexes to Properties?

Posted by Larry Meadors <lm...@apache.org>.
Dang it Jeff, you were too fast for me. :-P

Larry


On 4/11/07, Jeff Butler <je...@gmail.com> wrote:
> You can do it with a result map like this:
>
> <resultMap id="fredResult" class="somepackage.Fred">
>   <result property="id" columnIndex="1"/>
>   <result property="name" columnIndex="2"/>
> </resultMap>
>
> Jeff Butler
>
>
>
> On 4/11/07, Paul Sanders <te...@gmail.com> wrote:
> >
> > I have stored procedures that return Oracle REFCURSORs that I want to use
> > from iBATIS in Java. I've seen instructions on how to do this but I need
> to
> > be able to map column indexes to my bean properties rather than column
> > names.
> >
> > The reason for this is that our dba's, in their infinite wisdom, just
> > renamed all the columns in the latest version of our database to "meet
> > standards", but the changes are not being applied to the previous versions
> > that the application must still support. An "easy" fix is to have
> different
> > SQLMaps for each version but this is yucky. Better still would be to use
> > column indexes since the order has not changed, only the names.
> >
> > So far I haven't seen any way to do this, but I am brand new to iBATIS -
> > anyone got any ideas?
> >
> > Thanks
> >
> > Paul
> > --
> > View this message in context:
> http://www.nabble.com/Can-You-Map-Column-Indexes-to-Properties--tf3559865.html#a9941267
> > Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
> >
> >
>
>

Re: Can You Map Column Indexes to Properties?

Posted by Jeff Butler <je...@gmail.com>.
You can do it with a result map like this:

<resultMap id="fredResult" class="somepackage.Fred">
  <result property="id" columnIndex="1"/>
  <result property="name" columnIndex="2"/>
</resultMap>

Jeff Butler


On 4/11/07, Paul Sanders <te...@gmail.com> wrote:
>
>
> I have stored procedures that return Oracle REFCURSORs that I want to use
> from iBATIS in Java. I've seen instructions on how to do this but I need
> to
> be able to map column indexes to my bean properties rather than column
> names.
>
> The reason for this is that our dba's, in their infinite wisdom, just
> renamed all the columns in the latest version of our database to "meet
> standards", but the changes are not being applied to the previous versions
> that the application must still support. An "easy" fix is to have
> different
> SQLMaps for each version but this is yucky. Better still would be to use
> column indexes since the order has not changed, only the names.
>
> So far I haven't seen any way to do this, but I am brand new to iBATIS -
> anyone got any ideas?
>
> Thanks
>
> Paul
> --
> View this message in context:
> http://www.nabble.com/Can-You-Map-Column-Indexes-to-Properties--tf3559865.html#a9941267
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>