Return-Path: Delivered-To: apmail-incubator-ibatis-user-java-archive@www.apache.org Received: (qmail 10394 invoked from network); 22 Apr 2005 19:43:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 Apr 2005 19:43:32 -0000 Received: (qmail 51291 invoked by uid 500); 22 Apr 2005 19:43:58 -0000 Delivered-To: apmail-incubator-ibatis-user-java-archive@incubator.apache.org Received: (qmail 51268 invoked by uid 500); 22 Apr 2005 19:43:57 -0000 Mailing-List: contact ibatis-user-java-help@incubator.apache.org; run by ezmlm Precedence: bulk Reply-To: ibatis-user-java@incubator.apache.org List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list ibatis-user-java@incubator.apache.org Received: (qmail 51249 invoked by uid 99); 22 Apr 2005 19:43:57 -0000 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=FORGED_RCVD_HELO X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from ip60.post-legacy.dfw.ygnition.net (HELO localhost.localdomain) (66.135.183.60) by apache.org (qpsmtpd/0.28) with ESMTP; Fri, 22 Apr 2005 12:43:57 -0700 Received: from [10.0.0.25] (amfllc.com [67.105.101.82]) (authenticated bits=0) by localhost.localdomain (8.13.1/8.13.1) with ESMTP id j3MJh2oq005133 for ; Fri, 22 Apr 2005 14:43:02 -0500 User-Agent: Microsoft-Entourage/11.1.0.040913 Date: Fri, 22 Apr 2005 14:43:24 -0500 Subject: Re: Mapping of one object to several tables? From: Sasha Borodin To: Message-ID: In-Reply-To: <2fe5ef5b0504221239f0a44d8@mail.gmail.com> Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Can you even do an INSERT that involves multiple tables? -Sasha > From: Brandon Goodin > Reply-To: > Date: Fri, 22 Apr 2005 13:39:30 -0600 > To: > Subject: Re: Mapping of one object to several tables? > > If you are trying to prevent duplicate inserts you would need to > perform a select on the database to make sure it doesn't exist first. > > Brandon > > On 4/22/05, toto titi wrote: >> Hello, >> >> I am new to iBatis/SQL and don't really know if the >> following is possible or not.. Also, I am not sure >> where to ask this question as I don't know if it >> relates more to iBatis or SQL... so please bear with >> me. >> >> Let's say I want to save the following object: >> class person { >> String name; >> String country; >> } >> >> In order to save space in my db I will save the >> country in a table of its own and refer to each record >> from the name table by an id: >> >> personTable >> ----------- >> id >> name >> countryId >> >> countryTable >> ------------ >> id >> country >> >> Now, I know that for a select statement I can just do >> a join to get my object back: >> SELECT name, country from personTable, countryTable >> where countryId=countryTable.id; >> >> My question is, how do I insert a new person in these >> two tables with only one query? Taking into account >> that the country for the new person object might >> already have been inserted.. >> >> Thanks for any help! >> >> __________________________________________________ >> Do You Yahoo!? >> Tired of spam? Yahoo! Mail has the best spam protection around >> http://mail.yahoo.com >>