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 Jerry Jalenak <je...@gmail.com> on 2004/12/20 20:38:46 UTC

queryForObject with Preallocated Object

I am passing a value object from by business tier to my data tier, and
having sqlMaps use this  object in a queryForObject command :

<snip>

public void getUserByName(UserInfo ui)
   throws SQLException
{
    SqlMapClient sqlMap = getSqlMapClient();
    sqlMap.queryForObject("getUserInfo", ui.getUserName(), ui);
}

</snip>

The statement gets executed correctly, but the 'ui' object is not
getting filled with the result set.  Can any one point out what it is
I'm doing wrong?

Thanks!

Jerry Jalenak

Re: queryForObject with Preallocated Object

Posted by Jerry Jalenak <je...@gmail.com>.
<sheepish-look-on-face />

Never mind.  I *really* hate it when you realize that you're your own
worst enemy!

Jerry


On Tue, 21 Dec 2004 08:19:10 -0600, Jerry Jalenak
<je...@gmail.com> wrote:
> In the iBatis Developer Guide, page 43, there is a usage example that
> does not show the sqlMap.queryForObject needing a return value.  I
> have also tried your suggestion this morning, and end up with my 'ui'
> object set to null - not filled in the way I would expect it to be....
> 
> Jerry
> 
> 
> On Tue, 21 Dec 2004 13:42:44 +0100, Mikael Berglund
> <mi...@educ.umu.se> wrote:
> > Jerry Jalenak wrote:
> >
> > > public void getUserByName(UserInfo ui)
> > >    throws SQLException
> > > {
> > >     SqlMapClient sqlMap = getSqlMapClient();
> > >     sqlMap.queryForObject("getUserInfo", ui.getUserName(), ui);
> > > }
> > >
> > > </snip>
> > >
> > > The statement gets executed correctly, but the 'ui' object is not
> > > getting filled with the result set.  Can any one point out what it is
> > > I'm doing wrong?
> >
> > Hello,
> >
> > you have to assign the object returned by queryForObject()
> > to your variable.
> >
> >    ui = (UserInfo) sqlMap.queryForObject("getUserInfo",
> > ui.getUserName(), ui);
> >
> > Regards,
> > Mikael
> >
> >
>

Re: queryForObject with Preallocated Object

Posted by Jerry Jalenak <je...@gmail.com>.
In the iBatis Developer Guide, page 43, there is a usage example that
does not show the sqlMap.queryForObject needing a return value.  I
have also tried your suggestion this morning, and end up with my 'ui'
object set to null - not filled in the way I would expect it to be....

Jerry


On Tue, 21 Dec 2004 13:42:44 +0100, Mikael Berglund
<mi...@educ.umu.se> wrote:
> Jerry Jalenak wrote:
> 
> > public void getUserByName(UserInfo ui)
> >    throws SQLException
> > {
> >     SqlMapClient sqlMap = getSqlMapClient();
> >     sqlMap.queryForObject("getUserInfo", ui.getUserName(), ui);
> > }
> >
> > </snip>
> >
> > The statement gets executed correctly, but the 'ui' object is not
> > getting filled with the result set.  Can any one point out what it is
> > I'm doing wrong?
> 
> Hello,
> 
> you have to assign the object returned by queryForObject()
> to your variable.
> 
>    ui = (UserInfo) sqlMap.queryForObject("getUserInfo",
> ui.getUserName(), ui);
> 
> Regards,
> Mikael
> 
>