Java Mailing List Archive

Home » user-cs.ibatis »

dynamic statement (all parameter is dynamically generated)



Author LoginPost Reply

I used to use iBatisNet 1.0 and was using an abnormal way to generate sql for
Recently i want to move to the latest version, and found that the old way is
not work anymore.
I would lilke to ask if someone know how to do the same thing in latest

This is the normal way, predefined the column name & parameters
<insert id="insertsql" parameterClass="hashtable">
 insert into User (username, password) values (#username#, #password#)")

What i was doing is to define nothing in the mapped statements, but just a
<insert id="insertsql" parameterClass="hashtable">

In the code, i generate the statement dynamically according to waht i want
to insert:
Hashtable hashtable = new Hashtable();
hashtable.add("username", "admin");
hashtable.add("password", "password");
hashtable.add("strparam", "insert into User (username, password) values
(#username#, #password#)");
SqlMapper.Insert("insertsql", hashtable);

By generating SQL in this way, i can define only ONE <insert>..</insert> for
all case even if i have 1000 tables.
And this method works fine in 1.0 ( perhaps it may be a bug)

I know that i can generate the SQL in Stirng, but not hashtable:
<insert id="insertsql" parameterClass="string">
string strparam = "insert into User (username, password) values ('admin',
SqlMapper.Insert("insertsql", strparam);

But using String got problem when:
1) need to replace all ' into ''
2) the value is very very long, db field is storing entire code of a html

That's why i still want to implment the "hashtable" way
Is anyone got idea?

Thanks in advance!!!!
Sent from the iBATIS - User - Cs mailing list archive at

To unsubscribe, e-mail: user-cs-unsubscribe@(protected)
For additional commands, e-mail: user-cs-help@(protected)

©2008 - Jax Systems, LLC, U.S.A.