ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sheile <sheile1...@gmail.com>
Subject Re: Positional Parameters
Date Tue, 04 Aug 2009 05:32:58 GMT
Hi.

One of solution is this:

<sqlMap namespace="MyObject">
  <insert id="PERSIST" parameterClass="List">
    INSERT INTO my_table (f1, f2, f3) VALUES
    <iterate open="(" close=")" conjunction=",">
        #[]#
    </iterate>
  </insert>
</sqlMap>

Above solution use java.util.List, I don't know that how to use the Object[].

2009/8/4 Stephen Scheck <steves619@yahoo.com>:
> Can iBATIS support simple positional parameters for inserts? I want to do
> something like:
>
> <sqlMap namespace="MyObject">
>   <insert id="PERSIST">
>     INSERT INTO my_table (f1, f2, f3) VALUES (?, ?, ?)
>   </insert>
> </sqlMap>
>
> executor.startBatch();
> for (int objNum = 0; objNum < MAX_OBJ_NUM; objNum++) {
>     Object[] args = new Object[] {
>         objNum,
>         val1,
>         val2
>     };
>
>     executor.insert("PERSIST", args);
> }
>
> executor.executeBatch();
> // etc
>
> In the real case that I'm trying to implement, my fields come from several
> sources and I'd
> prefer to avoid creating an inner class just to make the data conform to a
> JavaBean.
>
> Thanks.
>
>
>

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


Mime
View raw message