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 apinke <ap...@gmail.com> on 2008/05/28 16:43:01 UTC

using a parameterClass and also passing some additional params..

Hi ,

I am using a abator generated Insert statement whose parameterClass is a
JavaBean class.

(psuedo syntax)
 <insert id="abatorgenerated_insert" parameterClass="org.test.DomainObject"
>
    insert into MYTABLE.. ..values
(#appName:VARCHAR#,...#callTime:TIMESTAMP#)
  </insert>

In addition to the above , I would also like to pass a schema name that can
be appended to the table as
"insert into $schema$.MYTABLE..."
THe schema name will change on the fly based on various conditions and hence
needs to be passed.
I dont want to change the DomainObject just to add this schema as it does
not belong there .

Is there a way I can use a parameterMap also so that I can store the schema
in that instead ? But how do I pass this additional Map to the SqlMapClient
insert(..) ? 

I am using Spring and the Spring SqlMapClientTemplate.

thanks
Pat
-- 
View this message in context: http://www.nabble.com/using-a-parameterClass-and-also-passing-some-additional-params..-tp17514280p17514280.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: using a parameterClass and also passing some additional params..

Posted by Jiming Liu <ji...@gmail.com>.
I vote for this feature for version 3!

On Wed, May 28, 2008 at 10:43 PM, apinke <ap...@gmail.com> wrote:

>
> Hi ,
>
> I am using a abator generated Insert statement whose parameterClass is a
> JavaBean class.
>
> (psuedo syntax)
>  <insert id="abatorgenerated_insert" parameterClass="org.test.DomainObject"
> >
>    insert into MYTABLE.. ..values
> (#appName:VARCHAR#,...#callTime:TIMESTAMP#)
>  </insert>
>
> In addition to the above , I would also like to pass a schema name that can
> be appended to the table as
> "insert into $schema$.MYTABLE..."
> THe schema name will change on the fly based on various conditions and
> hence
> needs to be passed.
> I dont want to change the DomainObject just to add this schema as it does
> not belong there .
>
> Is there a way I can use a parameterMap also so that I can store the schema
> in that instead ? But how do I pass this additional Map to the SqlMapClient
> insert(..) ?
>
> I am using Spring and the Spring SqlMapClientTemplate.
>
> thanks
> Pat
> --
> View this message in context:
> http://www.nabble.com/using-a-parameterClass-and-also-passing-some-additional-params..-tp17514280p17514280.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>

Re: using a parameterClass and also passing some additional params..

Posted by apinke <ap...@gmail.com>.
Well, what do you know ? 
I thought of trying the following right after posting...and it worked ! :-)

Here is how I got it to work :
Iinstead of passing the domain object , I pass a Map that contains it.

(psuedo syntax) 
 <insert id="testinsert" parameterClass="java.util.Map" > 
    insert into $schema$.MYTABLE.. ..values
(#record.appName:VARCHAR#,...#record.callTime:TIMESTAMP#) 
  </insert> 

and now I am passing the values in the Map

Map data = new HashMap();
data.put("schema","DUMMY");
data.put("record",record);
getSqlMapClientTemplate().insert("testinsert", data);

I think it is correct and will work. Checked the src for
IsPropertyAvailableTagHandler and looks like its handled as it resolves the
"." property...

thanks
Pat
-- 
View this message in context: http://www.nabble.com/using-a-parameterClass-and-also-passing-some-additional-params..-tp17514280p17534431.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: using a parameterClass and also passing some additional params..

Posted by apinke <ap...@gmail.com>.


apinke wrote:
> 
> Hi ,
> 
> I am using a abator generated Insert statement whose parameterClass is a
> JavaBean class.
> 
> (psuedo syntax)
>  <insert id="abatorgenerated_insert"
> parameterClass="org.test.DomainObject" >
>     insert into MYTABLE.. ..values
> (#appName:VARCHAR#,...#callTime:TIMESTAMP#)
>   </insert>
> 
> In addition to the above , I would also like to pass a schema name that
> can be appended to the table as
> "insert into $schema$.MYTABLE..."
> THe schema name will change on the fly based on various conditions and
> hence needs to be passed.
> I dont want to change the DomainObject just to add this schema as it does
> not belong there .
> 
> Is there a way I can use a parameterMap also so that I can store the
> schema in that instead ? But how do I pass this additional Map to the
> SqlMapClient insert(..) ? 
> 
> I am using Spring and the Spring SqlMapClientTemplate.
> 
> thanks
> Pat
> 

Anybody ? Any workaround or trick to do this ? Can I set some parameters
that are NOT a part of the parameterClass ?

thanks
Pat

-- 
View this message in context: http://www.nabble.com/using-a-parameterClass-and-also-passing-some-additional-params..-tp17514280p17534044.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.