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 oliverw <ol...@weichhold.com> on 2008/02/15 13:01:05 UTC

Auxiliary insert parameter

<insert id="insertItemName" parameterClass="com.foo.bar.model.ItemName" >
  INSERT INTO item_names (item_id, item_name, item_name_tsv, culture_id)
VALUES(#item_id#, #item_name#, to_tsvector(#ts_config#, #item_name#),
#culture_id# )
</insert>

In the above insert statement the #ts_config# is only needed as an argument
to the to_tsvector() function call. Thus I would like to avoid making
ts_config a member of the ItemName bean.

Unfortunately I am not sure how to pass the value of #ts_config# in addition
to the ItemName object to the insert statement. Any suggestions?
-- 
View this message in context: http://www.nabble.com/Auxiliary-insert-parameter-tp15499629p15499629.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Auxiliary insert parameter

Posted by oliverw <ol...@weichhold.com>.
If I could use a constant, I wouldn't have made it a variable in the first
place :) 


Chetan Nayak wrote:
> 
> why don't you just hard code it to some value .
> Something like to_tsvector(' ',#item_name#).
> Hope this helps
> 
> Thanks
> Chetan
> 
> 
> 
> On 2/15/08, oliverw <ol...@weichhold.com> wrote:
>>
>>
>> <insert id="insertItemName" parameterClass="com.foo.bar.model.ItemName" >
>> INSERT INTO item_names (item_id, item_name, item_name_tsv, culture_id)
>> VALUES(#item_id#, #item_name#, to_tsvector(#ts_config#, #item_name#),
>> #culture_id# )
>> </insert>
>>
>> In the above insert statement the #ts_config# is only needed as an
>> argument
>> to the to_tsvector() function call. Thus I would like to avoid making
>> ts_config a member of the ItemName bean.
>>
>> Unfortunately I am not sure how to pass the value of #ts_config# in
>> addition
>> to the ItemName object to the insert statement. Any suggestions?
>> --
>> View this message in context:
>> http://www.nabble.com/Auxiliary-insert-parameter-tp15499629p15499629.html
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Auxiliary-insert-parameter-tp15499629p15500707.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Auxiliary insert parameter

Posted by Chetan Nayak <ch...@gmail.com>.
why don't you just hard code it to some value .
Something like to_tsvector(' ',#item_name#).
Hope this helps

Thanks
Chetan



On 2/15/08, oliverw <ol...@weichhold.com> wrote:
>
>
> <insert id="insertItemName" parameterClass="com.foo.bar.model.ItemName" >
> INSERT INTO item_names (item_id, item_name, item_name_tsv, culture_id)
> VALUES(#item_id#, #item_name#, to_tsvector(#ts_config#, #item_name#),
> #culture_id# )
> </insert>
>
> In the above insert statement the #ts_config# is only needed as an
> argument
> to the to_tsvector() function call. Thus I would like to avoid making
> ts_config a member of the ItemName bean.
>
> Unfortunately I am not sure how to pass the value of #ts_config# in
> addition
> to the ItemName object to the insert statement. Any suggestions?
> --
> View this message in context:
> http://www.nabble.com/Auxiliary-insert-parameter-tp15499629p15499629.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>

Re: Auxiliary insert parameter

Posted by oliverw <ol...@weichhold.com>.
Interesting. I didn't know that IBatis will happily resolve nested property
identifiers. Thanks! I'll give this a a shot.


Dave.Derry wrote:
> 
> I'm no pro with ibatis, but you could probably use a Map
> 
> Map<String, Object> params = new HashMap<String, Object>();
> params.put("itemName", [instance of ItemName]);
> params.put("ts_config", [value of ts_config]);
> 
> then modify your insert statement
> 
> <insert id="insertItemName" parameterClass="map" >
>   INSERT INTO item_names (item_id, item_name, item_name_tsv, culture_id)
> VALUES(#itemName.item_id#, #itemName.item_name#, to_tsvector(#ts_config#,
> #itemName.item_name#),
> #itemName.culture_id# )
> </insert>
> 
> 
> I think this should work for you.
> 
> Dave
> 
> We must begin not just to act, but to think, for there is no better slave
> than the one who believes his slavery to be freedom, and we are in
> no greater peril than when we cannot see the chains on our minds
> because there are yet no chains on our feet.
> -- Michael Reid
> 
> 
> 
> 
>                                                                            
>              oliverw                                                       
>              <oliver@weichhold                                             
>              .com>                                                      To 
>                                        user-java@ibatis.apache.org         
>              02/15/2008 07:01                                           cc 
>              AM                                                            
>                                                                    Subject 
>                                        Auxiliary insert parameter          
>              Please respond to                                             
>              user-java@ibatis.                                             
>                 apache.org                                                 
>                                                                            
>                                                                            
>                                                                            
> 
> 
> 
> 
> 
> <insert id="insertItemName" parameterClass="com.foo.bar.model.ItemName" >
>   INSERT INTO item_names (item_id, item_name, item_name_tsv, culture_id)
> VALUES(#item_id#, #item_name#, to_tsvector(#ts_config#, #item_name#),
> #culture_id# )
> </insert>
> 
> In the above insert statement the #ts_config# is only needed as an
> argument
> to the to_tsvector() function call. Thus I would like to avoid making
> ts_config a member of the ItemName bean.
> 
> Unfortunately I am not sure how to pass the value of #ts_config# in
> addition
> to the ItemName object to the insert statement. Any suggestions?
> --
> View this message in context:
> http://www.nabble.com/Auxiliary-insert-parameter-tp15499629p15499629.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
> 
> 
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Auxiliary-insert-parameter-tp15499629p15500657.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Auxiliary insert parameter

Posted by Da...@Equifax.com.
I'm no pro with ibatis, but you could probably use a Map

Map<String, Object> params = new HashMap<String, Object>();
params.put("itemName", [instance of ItemName]);
params.put("ts_config", [value of ts_config]);

then modify your insert statement

<insert id="insertItemName" parameterClass="map" >
  INSERT INTO item_names (item_id, item_name, item_name_tsv, culture_id)
VALUES(#itemName.item_id#, #itemName.item_name#, to_tsvector(#ts_config#,
#itemName.item_name#),
#itemName.culture_id# )
</insert>


I think this should work for you.

Dave

We must begin not just to act, but to think, for there is no better slave
than the one who believes his slavery to be freedom, and we are in
no greater peril than when we cannot see the chains on our minds
because there are yet no chains on our feet.
-- Michael Reid




                                                                           
             oliverw                                                       
             <oliver@weichhold                                             
             .com>                                                      To 
                                       user-java@ibatis.apache.org         
             02/15/2008 07:01                                           cc 
             AM                                                            
                                                                   Subject 
                                       Auxiliary insert parameter          
             Please respond to                                             
             user-java@ibatis.                                             
                apache.org                                                 
                                                                           
                                                                           
                                                                           





<insert id="insertItemName" parameterClass="com.foo.bar.model.ItemName" >
  INSERT INTO item_names (item_id, item_name, item_name_tsv, culture_id)
VALUES(#item_id#, #item_name#, to_tsvector(#ts_config#, #item_name#),
#culture_id# )
</insert>

In the above insert statement the #ts_config# is only needed as an argument
to the to_tsvector() function call. Thus I would like to avoid making
ts_config a member of the ItemName bean.

Unfortunately I am not sure how to pass the value of #ts_config# in
addition
to the ItemName object to the insert statement. Any suggestions?
--
View this message in context:
http://www.nabble.com/Auxiliary-insert-parameter-tp15499629p15499629.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.