Capturing PL/SQL OUT parameter into a different object

216 views
Skip to first unread message

Romi Halimman

unread,
May 22, 2012, 6:49:26 PM5/22/12
to mybatis-user
Hi,

We are using MyBatis to call PL/SQL and we use a single Java object
that contains both the IN and OUT parameter.

We would like to utilize resultType for the OUT parameter. Is this
possible?

Thanks.

Dridi Boukelmoune

unread,
May 23, 2012, 2:59:27 AM5/23/12
to mybati...@googlegroups.com
Hi,

I've never done this, but I belive it should work the same as retrieving an autogenerated id after an insert.
The propery you are sending #{someProp} should have both a getter and a setter.

Dridi
http://www.zenika.com/
--
 

http://www.whatsnextparis.com/images/sign/ligne.jpg

Dridi Boukelmoune

Développeur/Formateur

GSM : +33 (0)6 17 91 14 23
dridi.bo...@zenika.com

http://www.whatsnextparis.com/images/sign/logo.jpg
51, rue le Peletier - 75009 Paris
Tel : +33 (0)1 45 26 19 15

http://www.whatsnextparis.com/images/sign/ligne.jpg

 
image001.jpg
image002.jpg

Romi Halimman

unread,
May 23, 2012, 8:29:19 AM5/23/12
to mybatis-user
Hi Dridi,

Thanks for your response.

What we are hoping is MyBatis can call get() method on one object for
IN parameters, and later call set() method on another object
(different Java class) for the OUT parameters. That way, we can have a
notation of "Request" object and "Response" object. Right now,
everything is in a single DTO class which has to contain properties
for IN and OUT.

Thanks,
Romi

On May 23, 1:59 am, Dridi Boukelmoune <dridi.boukelmo...@zenika.com>
wrote:
> Hi,
>
> I've never done this, but I belive it should work the same as retrieving an
> autogenerated id after an insert.
> The propery you are sending #{someProp} should have both a getter and a
> setter.
>
> Dridihttp://www.zenika.com/
>
> On Wed, May 23, 2012 at 12:49 AM, Romi Halimman <rha...@gmail.com> wrote:
> > Hi,
>
> > We are using MyBatis to call PL/SQL and we use a single Java object
> > that contains both the IN and OUT parameter.
>
> > We would like to utilize resultType for the OUT parameter. Is this
> > possible?
>
> > Thanks.
>
> --
>
> [image:http://www.whatsnextparis.com/images/sign/ligne.jpg]
>
> *Dridi Boukelmoune***
>
> Développeur/Formateur
>
> GSM : +33 (0)6 17 91 14 23
> dridi.boukelmo...@zenika.com
>  image001.jpg
> < 1KViewDownload
>
>  image002.jpg
> 4KViewDownload

Poitras Christian

unread,
May 23, 2012, 8:33:51 AM5/23/12
to mybati...@googlegroups.com
Hi,

I think MyBatis can handle a "Request" and "Response" object if you pass both parameters to the Mapper using @Param.

Christian

-----Message d'origine-----
De : mybati...@googlegroups.com [mailto:mybati...@googlegroups.com] De la part de Romi Halimman
Envoyé : May-23-12 8:29 AM
À : mybatis-user
Objet : Re: Capturing PL/SQL OUT parameter into a different object

Dridi Boukelmoune

unread,
May 23, 2012, 8:42:13 AM5/23/12
to mybati...@googlegroups.com
I thought @Param was only a helper to name parameters not embedded in an object :/ (instead of param1, param2 ...)
--
 

http://www.whatsnextparis.com/images/sign/ligne.jpg

Dridi Boukelmoune

Développeur/Formateur

dridi.bo...@zenika.com

http://www.whatsnextparis.com/images/sign/logo.jpg
51, rue le Peletier - 75009 Paris
Tel : +33 (0)1 45 26 19 15

http://www.whatsnextparis.com/images/sign/ligne.jpg

 
image002.jpg
image001.jpg

Frank Martínez

unread,
May 23, 2012, 8:50:00 AM5/23/12
to mybati...@googlegroups.com
Hi Guys,

What about a wrapper class for the parameter:

class CallParam<Req, Res> {
  Req request;
  Res response;
  public CallParam(Req req, Res res) {
    this.request = req;
    this.response = res;
  }
  public Req getRequest() { return request; }
  public Res getResponse() { return response; }
}

So you can use:

#{request.myInProperty} and #{response.myOutProperty, mode=OUT}

Too verbose?
--
Frank D. Martínez M.

image001.jpg
image002.jpg

Romi Halimman

unread,
May 24, 2012, 12:35:53 AM5/24/12
to mybatis-user
Hi Frank,

Thanks a lot. This design works pretty well for us. One small issue is
INOUT parameter. For that, we are going to capture the OUT in the
request and move it to response after MyBatis.

Thanks,
Romi
> --
> Frank D. Martínez M.
>
>  image001.jpg
> < 1KViewDownload
>
>  image002.jpg
> 4KViewDownload

Frank Martínez

unread,
May 24, 2012, 10:33:25 AM5/24/12
to mybati...@googlegroups.com
Hi Romi,

Nice to know it works for you.

Cheers,

Frank.
Reply all
Reply to author
Forward
0 new messages