Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 87522 invoked from network); 18 Apr 2008 14:48:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Apr 2008 14:48:50 -0000 Received: (qmail 68542 invoked by uid 500); 18 Apr 2008 14:48:48 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 68519 invoked by uid 500); 18 Apr 2008 14:48:48 -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 68508 invoked by uid 99); 18 Apr 2008 14:48:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Apr 2008 07:48:48 -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: domain of brandon.goodin@gmail.com designates 209.85.128.191 as permitted sender) Received: from [209.85.128.191] (HELO fk-out-0910.google.com) (209.85.128.191) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Apr 2008 14:48:05 +0000 Received: by fk-out-0910.google.com with SMTP id f40so2532987fka.0 for ; Fri, 18 Apr 2008 07:48:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=e2YSGyR3uLMEg1BnDgzpDUCAG1OekqR3A+WDTCtDQWw=; b=auhb7SyzF4PPjDj5Og+6C1Eu9ngVqLlYyeMLgizslRhWMQPUcCS1I5QE2VTxyqP1IMc00hPiY1B4mu+GVvvfL4J3Flrk96M5fsuleS3Bl6cXjtQmWvX7wzjd70MhQ8a0AYC34moAYGwnL8VJVH9Ia+TNUhv+d+sv7Yzzgkb488k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=LFJtCZ5CKgSzCeRyuKXCb1VwbZom1T18jYQccxOTMMOJG0cNyGnaTPPLPI4G8K5FLqIWBnkF4bi7m36bpFgOrprjmmfamS0AKE1dfLcW1mBbz8yZhAVLiJ0khqVWk9Z8lJZ9Qjhvu+30SnoI1C6jZeBKuqqIW6QqwuZcTT68s+k= Received: by 10.82.172.10 with SMTP id u10mr4566889bue.80.1208530093288; Fri, 18 Apr 2008 07:48:13 -0700 (PDT) Received: by 10.82.106.15 with HTTP; Fri, 18 Apr 2008 07:48:13 -0700 (PDT) Message-ID: <2fe5ef5b0804180748l36fc155fl2f256a1eb0a8a337@mail.gmail.com> Date: Fri, 18 Apr 2008 09:48:13 -0500 From: "Brandon Goodin" To: user-java@ibatis.apache.org Subject: Re: iBATIS insert does not execute In-Reply-To: <5fb0f140804180729x4b23e8ads63a7bfbe557bac49@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_3538_15513421.1208530093284" References: <5fb0f140804180510nd6f3d46yeb715e6a230496ca@mail.gmail.com> <2fe5ef5b0804180610s1746be4fpcab9dbfd04bf630d@mail.gmail.com> <5fb0f140804180729x4b23e8ads63a7bfbe557bac49@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_3538_15513421.1208530093284 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline What is your overall plan for deployment. Do you have sql scripts that get run against the target database to build the tables and such? How will you configure the connection url? What i've done in the past is to simply have a property file that contains the select key sql in it. I pass this property file in when my sqlmap is loaded and use the ${selectQuery} notation in my sqlmap. Brandon On Fri, Apr 18, 2008 at 9:29 AM, Chris Marshall wrote: > Sorry to bug you again but I think that the problem is related to > passing a null primary key in the insert statement when the key is > autogenerated (by MySQL). > What is the best practice here? I have tried the following MySQL > specific SqlMap snippet with success, but was hoping for a solution > portable among databases: > > > > select LAST_INSERT_ID() AS value > > insert into role (RoleID, ParentID, Name, Notes) > values (#roleid:INTEGER#, #parentid:INTEGER#, #name:VARCHAR#, > #notes:VARCHAR#) > > > Thanks Chris > > On 18/04/2008, Brandon Goodin wrote: > > Is this the only insert that is not working for you? Do you have others > that > > are working? What version of iBATIS are you using? > > > > Brandon Goodin > ------=_Part_3538_15513421.1208530093284 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline What is your overall plan for deployment. Do you have sql scripts that get run against the target database to build the tables and such? How will you configure the connection url? What i've done in the past is to simply have a property file that contains the select key sql in it. I pass this property file in when my sqlmap is loaded and use the ${selectQuery} notation in my sqlmap.

Brandon

On Fri, Apr 18, 2008 at 9:29 AM, Chris Marshall <chris@campsbayterrace.com> wrote:
Sorry to bug you again but I think that the problem is related to
passing a null primary key in the insert statement when the key is
autogenerated (by MySQL).
What is the best practice here?  I have tried the following MySQL
specific SqlMap snippet with success, but was hoping for a solution
portable among databases:

 <insert id="insert" parameterClass="net.mycompany.Role">
         <selectKey resultClass="java.lang.Integer" keyProperty="roleid">
               select LAST_INSERT_ID() AS value
         </selectKey>
   insert into role (RoleID, ParentID, Name, Notes)
   values (#roleid:INTEGER#, #parentid:INTEGER#, #name:VARCHAR#,
#notes:VARCHAR#)
 </insert>

Thanks Chris

On 18/04/2008, Brandon Goodin <brandon.goodin@gmail.com> wrote:
> Is this the only insert that is not working for you? Do you have others that
> are working? What version of iBATIS are you using?
>
> Brandon Goodin

------=_Part_3538_15513421.1208530093284--