ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abchau <chau...@gmail.com>
Subject dynamic statement (all parameter is dynamically generated)
Date Sat, 17 Jul 2010 18:31:49 GMT

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!!!!
View this message in context: http://old.nabble.com/dynamic-statement-%28all-parameter-is-dynamically-generated%29-tp29192888p29192888.html
Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.

To unsubscribe, e-mail: user-cs-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-cs-help@ibatis.apache.org

View raw message