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 Darren Davison <da...@davisononline.org> on 2008/04/15 15:04:22 UTC

Re: stored proc call with list items in parameter

we're still struggling with this, using a fairly unsatisfactory
workaround.. is there no way for iBATIS to parse such a thing?  I think
the notation I'm trying to use is standard OGNL.. not sure what iBATIS
is using.

Any pointers would be appreciated :)

Darren.


On Tue, Jan 22, 2008 at 11:38:05AM +0000, Darren Davison wrote:
> hi,
> 
> is it possible to refer to list items from a parameter class in a call
> to a stored proc?
> 
> If I have a class as follows that I use as a paramaterClass:
> 
> class Foo {
>   List<Bar> bar;
>   String name;
> 
>   // getters/setters omitted
> }
> 
> class Bar {
>   String name;
>   //getters/setters omitted
> }
> 
> 
> .. and a SP mapping as follows:
> 
> <procedure id="testSP"
> parameterClass="com.example.Foo">
> { CALL my_pkg.odd_sp_using_foo (
>   #foo.name,mode=IN#,
>   #foo.bar[0].name,mode=IN#)
> }
> </procedure>
> 
> obviously the above fails with;
> There is no READABLE property named 'bar[0]' in class
> com.example.Foo
> 
> Is there a way to make this work so that I can refer to indexed elements
> in the list of Bar instances?
> 
> Cheers,
> 
> -- 
> Darren Davison
> Public Key: 0xE855B3EA



-- 
Darren Davison
Public Key: 0xE855B3EA

Re: stored proc call with list items in parameter

Posted by Brandon Goodin <br...@gmail.com>.
There are several reason we don't use OGNL, none of which have anything to
do with the quality of OGNL as a specification. I would say the primary
reason we don't use OGNL is because it just wasn't that well known when we
started iBATIS. As time marched on it was easier to continue to support the
manner in which we parse properties and values. The parsing is very integral
to the iBATIS code base. So, hooking in OGNL would not be a simple task.
Additionally, the iBATIS project has a zero dependency policy. This means
that we would not want iBATIS to depend on an additional jar in order to
accomplish what it is designed to do. This is because our belief is that
iBATIS isn't complex enough to "require" any external jars.
That being said we are certainly not against designing towards flexibility
if it makes sense. In the case you have outlined it certainly points towards
a need and the OGNL specification has some great features. As we work on
iBATIS 3 perhaps we can incorporate the OGNL specification into how we
access properties. I completely agree with you that the current
implementation could stand to be more powerful. I did notice a couple issue
in JIRA for this issue. Perhaps you can vote on those or make a whole new
JIRA issue that is more specific about desiring the use of the OGNL
specification in iBATIS 3.
Brandon


On Wed, Apr 16, 2008 at 2:20 PM, Darren Davison <da...@davisononline.org>
wrote:

> On Tue, Apr 15, 2008 at 08:48:36AM -0500, Brandon Goodin wrote:
> >    We've looked into this in the past and for whatever reason haven't
> added
> >    this feature. I think there were some difficulties. There is
> currently not
> >    a way to refer to a particular index of a list in a parameter using
> >    notation. You could flatten your parameters into a Map  and then pass
> the
> >    map in as a parameter object. Please let me know if this is suitable
> for
> >    your situation. If not, please expound on why it will not work for
> you.
>
> hi Brandon, thanks for the reply.
>
> Using the domain instance "as-is" is obviously more convenient than
> putting them all in a map - especially when some of those objects are
> quite complex and the SP needs various bits from several related
> objects.
>
> We do have a workaround, but we just wondered whether we were missing
> something in the object access notation.
>
> Out of interest, what was the difficulty you encountered?  Are you using
> OGNL (or if not, did you try it)?
>
> Cheers!
>
> --
> Darren Davison
> Public Key: 0xE855B3EA
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
>
> iD8DBQFIBlFpVgOfSOhVs+oRAijqAKCq/CX4i60pmJ6t3JhGnW6ynyNxuACcD5fs
> HNsXCxfa40vqd5NuwwyH8/s=
> =xLbF
> -----END PGP SIGNATURE-----
>
>

Re: stored proc call with list items in parameter

Posted by Darren Davison <da...@davisononline.org>.
On Tue, Apr 15, 2008 at 08:48:36AM -0500, Brandon Goodin wrote:
>    We've looked into this in the past and for whatever reason haven't added
>    this feature. I think there were some difficulties. There is currently not
>    a way to refer to a particular index of a list in a parameter using
>    notation. You could flatten your parameters into a Map  and then pass the
>    map in as a parameter object. Please let me know if this is suitable for
>    your situation. If not, please expound on why it will not work for you.

hi Brandon, thanks for the reply.

Using the domain instance "as-is" is obviously more convenient than
putting them all in a map - especially when some of those objects are
quite complex and the SP needs various bits from several related
objects.

We do have a workaround, but we just wondered whether we were missing
something in the object access notation.

Out of interest, what was the difficulty you encountered?  Are you using
OGNL (or if not, did you try it)?

Cheers!

-- 
Darren Davison
Public Key: 0xE855B3EA

Re: stored proc call with list items in parameter

Posted by Brandon Goodin <br...@gmail.com>.
We've looked into this in the past and for whatever reason haven't added
this feature. I think there were some difficulties. There is currently not a
way to refer to a particular index of a list in a parameter using notation.
You could flatten your parameters into a Map  and then pass the map in as a
parameter object. Please let me know if this is suitable for your situation.
If not, please expound on why it will not work for you.

Brandon Goodin

On Tue, Apr 15, 2008 at 8:04 AM, Darren Davison <da...@davisononline.org>
wrote:

> we're still struggling with this, using a fairly unsatisfactory
> workaround.. is there no way for iBATIS to parse such a thing?  I think
> the notation I'm trying to use is standard OGNL.. not sure what iBATIS
> is using.
>
> Any pointers would be appreciated :)
>
> Darren.
>
>
> On Tue, Jan 22, 2008 at 11:38:05AM +0000, Darren Davison wrote:
> > hi,
> >
> > is it possible to refer to list items from a parameter class in a call
> > to a stored proc?
> >
> > If I have a class as follows that I use as a paramaterClass:
> >
> > class Foo {
> >   List<Bar> bar;
> >   String name;
> >
> >   // getters/setters omitted
> > }
> >
> > class Bar {
> >   String name;
> >   //getters/setters omitted
> > }
> >
> >
> > .. and a SP mapping as follows:
> >
> > <procedure id="testSP"
> > parameterClass="com.example.Foo">
> > { CALL my_pkg.odd_sp_using_foo (
> >   #foo.name,mode=IN#,
> >   #foo.bar[0].name,mode=IN#)
> > }
> > </procedure>
> >
> > obviously the above fails with;
> > There is no READABLE property named 'bar[0]' in class
> > com.example.Foo
> >
> > Is there a way to make this work so that I can refer to indexed elements
> > in the list of Bar instances?
> >
> > Cheers,
> >
> > --
> > Darren Davison
> > Public Key: 0xE855B3EA
>
>
>
> --
> Darren Davison
> Public Key: 0xE855B3EA
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
>
> iD8DBQFIBKfVVgOfSOhVs+oRAm+/AKCm+xZt98WkCn+D5TtNBWaXIV3RTwCfctB/
> zsHloRGYRbr8f1Pf0+dJ22k=
> =6qAo
> -----END PGP SIGNATURE-----
>
>