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 aleksey2 <al...@ms.com> on 2008/06/27 17:56:14 UTC

populate same instance

Transfer tr1 = new Transfer();
tr.setId(123);
Transfer tr2 = getSqlMapper().queryForObject("selectTransferByRefId",tr1);

In the above code I get back a new instance of the Transfer object. Is there
any way to get tr1 Transfer object populated by the query?

Thanks
Aleksey
-- 
View this message in context: http://www.nabble.com/populate-same-instance-tp18158016p18158016.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


RE: populate same instance

Posted by "Shannon, Bryan" <BS...@Tribune.com>.
You can use the three argument form of queryForObject(), which takes a
bean as the third argument... Unless I'm missing something you said.
Pass in the partially filled bean as the third argument, and ibatis will
populate that base on the query instead of creating a new instance.

-Bryan Shannon
 

-----Original Message-----
From: aleksey2 [mailto:aleksey.shevchenko@ms.com] 
Sent: Monday, June 30, 2008 9:26 AM
To: user-java@ibatis.apache.org
Subject: Re: populate same instance


I want my input object to be returned as output.  Is that possible?



Nicholoz Koka Kiknadze wrote:
> 
> No as long as you want to avoid new object creation. But
> 
> tr1 = getSqlMapper().queryForObject("selectTransferByRefId",tr1)
> 
> do I miss anything?
> 
> 
> 
> On Fri, Jun 27, 2008 at 7:56 PM, aleksey2 <al...@ms.com>
> wrote:
> 
>>
>> Transfer tr1 = new Transfer();
>> tr.setId(123);
>> Transfer tr2 =
>> getSqlMapper().queryForObject("selectTransferByRefId",tr1);
>>
>> In the above code I get back a new instance of the Transfer object. 
>> Is there any way to get tr1 Transfer object populated by the query?
>>
>> Thanks
>> Aleksey
>> --
>> View this message in context:
>> http://www.nabble.com/populate-same-instance-tp18158016p18158016.html
>> Sent from the iBATIS - User - Java mailing list archive at
Nabble.com.
>>
>>
> 
> 

--
View this message in context:
http://www.nabble.com/populate-same-instance-tp18158016p18195653.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: populate same instance

Posted by aleksey2 <al...@ms.com>.
I want my input object to be returned as output.  Is that possible?



Nicholoz Koka Kiknadze wrote:
> 
> No as long as you want to avoid new object creation. But
> 
> tr1 = getSqlMapper().queryForObject("selectTransferByRefId",tr1)
> 
> do I miss anything?
> 
> 
> 
> On Fri, Jun 27, 2008 at 7:56 PM, aleksey2 <al...@ms.com>
> wrote:
> 
>>
>> Transfer tr1 = new Transfer();
>> tr.setId(123);
>> Transfer tr2 =
>> getSqlMapper().queryForObject("selectTransferByRefId",tr1);
>>
>> In the above code I get back a new instance of the Transfer object. Is
>> there
>> any way to get tr1 Transfer object populated by the query?
>>
>> Thanks
>> Aleksey
>> --
>> View this message in context:
>> http://www.nabble.com/populate-same-instance-tp18158016p18158016.html
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/populate-same-instance-tp18158016p18195653.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: populate same instance

Posted by Nicholoz Koka Kiknadze <ki...@gmail.com>.
No as long as you want to avoid new object creation. But

tr1 = getSqlMapper().queryForObject("selectTransferByRefId",tr1)

do I miss anything?



On Fri, Jun 27, 2008 at 7:56 PM, aleksey2 <al...@ms.com> wrote:

>
> Transfer tr1 = new Transfer();
> tr.setId(123);
> Transfer tr2 = getSqlMapper().queryForObject("selectTransferByRefId",tr1);
>
> In the above code I get back a new instance of the Transfer object. Is
> there
> any way to get tr1 Transfer object populated by the query?
>
> Thanks
> Aleksey
> --
> View this message in context:
> http://www.nabble.com/populate-same-instance-tp18158016p18158016.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>