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 Warren <wa...@clarksnutrition.com> on 2007/07/29 00:17:06 UTC

Question on using queryForObject(statementName, parameterObject, resultObject);

I have an item object that has a tax object that has a description field 
I need to set. I want to use the item object as the parameter and the 
same object as the result.

sqlMap.queryForObject("getTax", item, item);

<select id="getItemTax" parameterClass="item">
   SELECT TAX_Name AS tax.description FROM ...
</select>

It is the tax.description that is getting me in trouble. How do I write 
this or escape this? Or am I doing this completely wrong?

-- 
Thanks,

Warren Bell

Re: Question on using queryForObject(statementName, parameterObject, resultObject);

Posted by frontwall <fr...@gmail.com>.
Yes, you right.

2007/7/30, Warren <wa...@clarksnutrition.com>:
> What happens when the statement returns no records? Does the item result
> Object get returned without the tax.description field set?
>
> ARAI Hiroyuki wrote:
> > Hi, Warren
> >
> > At first, you have to set resultClass/resultMap attribute in select element.
> >
> > Then, when you want to use nested JavaBean(i.e. tax object in item),
> > you have to use ResultMap.
> >
> > for example:
> >
> > <resultMap id="itemMap" class="com.example.Item">
> >   <result property="tax.description" column="TAX_NAME" />
> > </resultMap>
> >
> > <select id="getItemTax" parameterClass="item" resultMap="itemMap">
> >    SELECT TAX_Name FROM ...
> > </select>
> >
> > thanks,
> >
>
>
> --
> Thanks,
>
> Warren Bell
> Systems Administrator
> Clark's Nutritional Centers
> 4225 Market St.
> Riverside, CA 92501
> 951-321-1960 ext. 142
> 909-645-8864 mobile
>

Re: Question on using queryForObject(statementName, parameterObject, resultObject);

Posted by Warren <wa...@clarksnutrition.com>.
What happens when the statement returns no records? Does the item result 
Object get returned without the tax.description field set?

ARAI Hiroyuki wrote:
> Hi, Warren
> 
> At first, you have to set resultClass/resultMap attribute in select element.
> 
> Then, when you want to use nested JavaBean(i.e. tax object in item),
> you have to use ResultMap.
> 
> for example:
> 
> <resultMap id="itemMap" class="com.example.Item">
>   <result property="tax.description" column="TAX_NAME" />
> </resultMap>
> 
> <select id="getItemTax" parameterClass="item" resultMap="itemMap">
>    SELECT TAX_Name FROM ...
> </select>
> 
> thanks,
> 


-- 
Thanks,

Warren Bell
Systems Administrator
Clark's Nutritional Centers
4225 Market St.
Riverside, CA 92501
951-321-1960 ext. 142
909-645-8864 mobile

Re: Question on using queryForObject(statementName, parameterObject, resultObject);

Posted by ARAI Hiroyuki <fr...@gmail.com>.
Hi, Warren

At first, you have to set resultClass/resultMap attribute in select element.

Then, when you want to use nested JavaBean(i.e. tax object in item),
you have to use ResultMap.

for example:

<resultMap id="itemMap" class="com.example.Item">
  <result property="tax.description" column="TAX_NAME" />
</resultMap>

<select id="getItemTax" parameterClass="item" resultMap="itemMap">
   SELECT TAX_Name FROM ...
</select>

thanks,

-- 
frontwall

2007/7/29, Warren <wa...@clarksnutrition.com>:
>  I have an item object that has a tax object that has a description field
> I need to set. I want to use the item object as the parameter and the
> same object as the result.
>
> sqlMap.queryForObject("getTax", item, item);
>
> <select id="getItemTax" parameterClass="item">
>    SELECT TAX_Name AS tax.description FROM ...
> </select>
>
> It is the tax.description that is getting me in trouble. How do I write
> this or escape this? Or am I doing this completely wrong?
>
> --
> Thanks,
>
> Warren Bell
>