Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 87337 invoked from network); 27 Oct 2008 15:30:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Oct 2008 15:30:19 -0000 Received: (qmail 14240 invoked by uid 500); 27 Oct 2008 15:30:22 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 13910 invoked by uid 500); 27 Oct 2008 15:30:21 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 13899 invoked by uid 99); 27 Oct 2008 15:30:20 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Oct 2008 08:30:20 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [80.12.242.101] (HELO smtp28.orange.fr) (80.12.242.101) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Oct 2008 15:29:07 +0000 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2823.orange.fr (SMTP Server) with ESMTP id 1969170000B5 for ; Mon, 27 Oct 2008 16:29:46 +0100 (CET) Received: from [127.0.0.1] (AToulouse-158-1-100-228.w90-11.abo.wanadoo.fr [90.11.15.228]) by mwinf2823.orange.fr (SMTP Server) with ESMTP id D00B670000B2 for ; Mon, 27 Oct 2008 16:29:45 +0100 (CET) X-ME-UUID: 20081027152945852.D00B670000B2@mwinf2823.orange.fr Message-ID: <4905DE8B.7000107@wanadoo.fr> Date: Mon, 27 Oct 2008 16:30:19 +0100 From: Pascal Jacob User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: user-java@ibatis.apache.org Subject: Re: dynamic CREATE TABLE woe References: <48FE1C58.2080707@wanadoo.fr> <48FF93F9.50703@wanadoo.fr> <93B0CB1886D4CC48823246865D80DC9402FC1365E7E1@HERMES.ircm.priv> <4900D377.1080109@wanadoo.fr> <93B0CB1886D4CC48823246865D80DC9402FC1365E7E6@HERMES.ircm.priv> In-Reply-To: <93B0CB1886D4CC48823246865D80DC9402FC1365E7E6@HERMES.ircm.priv> Content-Type: multipart/alternative; boundary="------------040100070608000607060701" X-Virus-Checked: Checked by ClamAV on apache.org This is a multi-part message in MIME format. --------------040100070608000607060701 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit https://issues.apache.org/jira/browse/IBATIS-550 Poitras Christian wrote: > Can you add it to JIRA and submit your patch? > http://issues.apache.org/jira/browse/IBATIS > > This will greatly help to add it to main build. > > Christian > > -----Original Message----- > From: Pascal Jacob [mailto:zartc@wanadoo.fr] > Sent: Thursday, October 23, 2008 3:42 PM > To: user-java@ibatis.apache.org > Subject: Re: dynamic CREATE TABLE woe > > I finally achieve success with my original SQLScript by patching ibatis instead of having to do convoluted things in my source code that I could not stand before a QA session. > in file: > ibatis-2.3.4.726\src\ibatis-src\com\ibatis\common\beans\ProbeFactory.java > in method: getProbe(), line: 33 > replaced: return GENERIC; > by: return BEAN; > > Hope this will make its way into the main build. > > regards. > > > Poitras Christian wrote: > >> This is a bug in how iBATIS handles maps inside a list parameter. >> Curiously, using #[].name# and #[].type# gave the expected result, but not $[].name$ and $[].type$... >> >> You can use a simple patch by putting your list of maps inside a map: >> private Map>> prepareCreateTableParams( >> final String[] columnNames, final String[] columnTypes) { >> Map>> ret = new HashMap>>(); >> List> params = >> new ArrayList>(); >> for(int i = 0; i < columnNames.length; i++) { >> HashMap map = new HashMap(); >> map.put("name", columnNames[i]); >> map.put("type", columnTypes[i]); >> params.add(map); >> } >> ret.put("list", params); >> return ret; >> } >> >> And in xml: >> >> CREATE TABLE data >> >> $list[].name$ $list[].type$ >> >> >> >> >> This should work. >> >> Christian >> >> >> -----Original Message----- >> From: Pascal Jacob [mailto:zartc@wanadoo.fr] >> Sent: Wednesday, October 22, 2008 4:59 PM >> To: user-java@ibatis.apache.org >> Subject: Re: dynamic CREATE TABLE woe >> >> Investigating more, I found the following evidences in the PreparedStatement sent by iBatis (I finally found the way to make iBatis log under SLF4J): >> >> 22:29:39.296 [DEBUG] [main] [java.sql.PreparedStatement:26] - {pstm-100002} Executing Statement: >> CREATE TABLE seqnsdb.seqnsdata ( {name=ID, type=INTEGER} {name=ID, >> type=INTEGER}, {name=ARISING_SEQ_ID, type=INTEGER} >> {name=ARISING_SEQ_ID, type=INTEGER}, {name=AC_SERIAL_NO, >> type=VARCHAR(255)} {name=AC_SERIAL_NO, type=VARCHAR(255)} ... ) >> >> It is evident that iBatis is not transforming the SQLScript as expected ! >> It seems like the whole Map.Entry is printed each time instead of only the name value first then only the type value. >> AAMOF I did replace $[].name$ and $[].type$ by simply $[]$ in the >> script and get the exact same result, which confirms that $[].name$ >> don't do anything more than $[]$ which is obviously not what is >> expected (or there is something i didn't understood) >> >> Hope this helps someone helping me ;) >> >> Tanks in advance. >> >> ---------------------------------------------------------------------- >> ----------------- Orange vous informe que cet e-mail a ete controle >> par l'anti-virus mail. >> Aucun virus connu a ce jour par nos services n'a ete detecte. >> >> >> >> >> > > --------------------------------------------------------------------------------------- > Orange vous informe que cet e-mail a ete controle par l'anti-virus mail. > Aucun virus connu a ce jour par nos services n'a ete detecte. > > > > --------------040100070608000607060701 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit https://issues.apache.org/jira/browse/IBATIS-550

Poitras Christian wrote:
Can you add it to JIRA and submit your patch?
http://issues.apache.org/jira/browse/IBATIS

This will greatly help to add it to main build.

Christian

-----Original Message-----
From: Pascal Jacob [mailto:zartc@wanadoo.fr]
Sent: Thursday, October 23, 2008 3:42 PM
To: user-java@ibatis.apache.org
Subject: Re: dynamic CREATE TABLE woe

I finally achieve success with my original SQLScript by patching ibatis instead of having to do convoluted things in my source code that I could not stand before a QA session.
in file:
ibatis-2.3.4.726\src\ibatis-src\com\ibatis\common\beans\ProbeFactory.java
in method: getProbe(), line: 33
replaced: return GENERIC;
by: return BEAN;

Hope this will make its way into the main build.

regards.


Poitras Christian wrote:
  
This is a bug in how iBATIS handles maps inside a list parameter.
Curiously, using #[].name# and #[].type# gave the expected result, but not $[].name$ and $[].type$...

You can use a simple patch by putting your list of maps inside a map:
    private Map<String, List<Map<String, String>>> prepareCreateTableParams(
            final String[] columnNames, final String[] columnTypes) {
        Map<String, List<Map<String, String>>> ret = new HashMap<String, List<Map<String, String>>>();
        List<Map<String, String>> params =
            new ArrayList<Map<String, String>>();
        for(int i = 0; i < columnNames.length; i++) {
            HashMap<String, String> map = new HashMap<String, String>();
            map.put("name", columnNames[i]);
            map.put("type", columnTypes[i]);
            params.add(map);
        }
        ret.put("list", params);
        return ret;
    }

And in xml:
    <statement id="create-table" parameterClass="map">
        CREATE TABLE data
            <iterate open="(" close=")" conjunction="," property="list">
                $list[].name$ $list[].type$
            </iterate>
    </statement>


This should work.

Christian


-----Original Message-----
From: Pascal Jacob [mailto:zartc@wanadoo.fr]
Sent: Wednesday, October 22, 2008 4:59 PM
To: user-java@ibatis.apache.org
Subject: Re: dynamic CREATE TABLE woe

Investigating more, I found the following evidences in the PreparedStatement sent by iBatis (I finally found the way to make iBatis log under SLF4J):

22:29:39.296 [DEBUG] [main] [java.sql.PreparedStatement:26] - {pstm-100002} Executing Statement:
CREATE TABLE seqnsdb.seqnsdata ( {name=ID, type=INTEGER} {name=ID,
type=INTEGER}, {name=ARISING_SEQ_ID, type=INTEGER}
{name=ARISING_SEQ_ID, type=INTEGER}, {name=AC_SERIAL_NO,
type=VARCHAR(255)} {name=AC_SERIAL_NO, type=VARCHAR(255)} ... )

It is evident that iBatis is not transforming the SQLScript as expected !
It seems like the whole Map.Entry is printed each time instead of only the name value first then only the type value.
AAMOF I did replace $[].name$ and $[].type$ by simply  $[]$ in the
script and get the exact same result, which confirms that $[].name$
don't do anything more than $[]$ which is obviously not what is
expected (or there is something i didn't understood)

Hope this helps someone helping me ;)

Tanks in advance.

----------------------------------------------------------------------
----------------- Orange vous informe que cet  e-mail a ete controle
par l'anti-virus mail.
Aucun virus connu a ce jour par nos services n'a ete detecte.




    

---------------------------------------------------------------------------------------
Orange vous informe que cet  e-mail a ete controle par l'anti-virus mail. 
Aucun virus connu a ce jour par nos services n'a ete detecte.



  
--------------040100070608000607060701--