Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 87190 invoked from network); 18 Aug 2005 10:14:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 Aug 2005 10:14:14 -0000 Received: (qmail 37553 invoked by uid 500); 18 Aug 2005 10:13:50 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 37520 invoked by uid 500); 18 Aug 2005 10:13:49 -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 37484 invoked by uid 99); 18 Aug 2005 10:13:48 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Aug 2005 03:13:47 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [196.35.77.56] (HELO mfw1.busgateway.is.co.za) (196.35.77.56) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Aug 2005 03:14:05 -0700 Received: from BG-SMTP02.he.businessgateway.co.za (Not Verified[196.35.61.110]) by mfw1.busgateway.is.co.za with NetIQ MailMarshal (v5.5.6.7) id ; Thu, 18 Aug 2005 12:18:38 +0200 Received: from meindert ([165.146.169.9]) by BG-SMTP02.he.businessgateway.co.za with Microsoft SMTPSVC(6.0.3790.211); Thu, 18 Aug 2005 12:13:37 +0200 From: "Meindert" To: , Subject: RE: Getting auto-generated keys in mySql Date: Thu, 18 Aug 2005 12:13:37 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1250" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 Thread-Index: AcWjdSBmy/JGSyRaQRKOsiBcjAAlsQAZqyuA X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 In-Reply-To: Message-ID: X-OriginalArrivalTime: 18 Aug 2005 10:13:38.0155 (UTC) FILETIME=[800FDBB0:01C5A3DD] X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi all, I forgot to use the mysql syntax and it still worked.... INSERT INTO StateAccess(SupervisorLevel, GroupId, EmpId, LayoutId) VALUES(#supervisorLevel#, #groupId#, #empId#, #layoutId#) SELECT @@IDENTITY AS ID Populated state.getOwnerAccess.stateAccessId just fine ! Don't know why! Using mysql 4.1.8 ibatis 2.1.5 build# 582 I only noticed today that the SqlMapClient API methode insert() returns the primairy key value of the newly inserted row. MEINDERT HOVING -----Original Message----- From: Larry Meadors [mailto:larry.meadors@gmail.com] Sent: 17 August 2005 11:46 PM To: user-java@ibatis.apache.org Subject: Re: Getting auto-generated keys in mySql NO! That is really, really not thread safe! Imagine what happens when 2 ppl do inserts at the same time... [insert #1][insert #2][query #1][query #2] Both [query #1] and [query #2] return the same id. Ooops! kaboom! Larry On 8/17/05, Alan Hicks wrote: > Hi Brian, > > I had the same problem and could not find any working examples. Finally I > stumbled upon > the query where 'userId' is an auto-generated key in my mysql table. If > you replace the > query you have with this one you should be in business. > > > SELECT MAX(userId) FROM tb_user > > > Hope this helps. > > Alan. > > > > On Wed, 17 Aug 2005 21:43:05 +0100, Barnett, Brian W. > wrote: > > > We've been using SQL Server and are moving to mySQL. Can somebody tell me > > how to do this for mySql: > > > > > > SELECT @@IDENTITY AS id > > > > > > TIA, > > Brian Barnett > > > > **************************************************************************** > > This email may contain confidential material. > > If you were not an intended recipient, > > Please notify the sender and delete all copies. > > We may monitor email to and from our network. > > **************************************************************************** > > > > > > > > > > -- > Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ > -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.10/73 - Release Date: 15/08/2005 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.12/75 - Release Date: 17/08/2005