Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 17387 invoked from network); 9 May 2006 06:36:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 9 May 2006 06:36:09 -0000 Received: (qmail 70844 invoked by uid 500); 9 May 2006 06:36:02 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 70818 invoked by uid 500); 9 May 2006 06:36:01 -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 70807 invoked by uid 99); 9 May 2006 06:36:01 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 May 2006 23:36:01 -0700 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=HTML_MESSAGE,HTML_TAG_EXIST_TBODY,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of phpmonkey@gmail.com designates 64.233.182.184 as permitted sender) Received: from [64.233.182.184] (HELO nf-out-0910.google.com) (64.233.182.184) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 May 2006 23:35:59 -0700 Received: by nf-out-0910.google.com with SMTP id b2so1123320nfe for ; Mon, 08 May 2006 23:35:38 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=uRkrjUVfaLyJ58RniIJwaP3Z+Av0BepDDq5Gt/feJvI54PUfP0MkMzSKBF68TSnJsqbckIzjmnWWEwcH6Q8QGjnz58SxYZ/UkNkxmI1iCArM7HIW1Ed2mJOwIRbQlgvZQQwdXwMvLNpCQvUlJ+zpskFbkj6ZOvrF+a185W9q//c= Received: by 10.49.35.17 with SMTP id n17mr1830757nfj; Mon, 08 May 2006 23:35:37 -0700 (PDT) Received: by 10.49.4.6 with HTTP; Mon, 8 May 2006 23:35:37 -0700 (PDT) Message-ID: <1d40f7c0605082335k7f1f3491h3547a9660a84d402@mail.gmail.com> Date: Mon, 8 May 2006 20:35:37 -1000 From: "Jerome Gagner" To: user-java@ibatis.apache.org Subject: Re: I am new to iBatis. Is it possible to insert into multiple tables using one parameter class using iBatis In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_23907_28283250.1147156537367" References: X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_23907_28283250.1147156537367 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline public class Product { private String name; private Integer id; public String getName() { return name; } public void setName(String name) { this.name =3D name; } public Integer getId() { return id; } public void setId(Integer id) { this.id =3D id; } } public class Service { private Integer name; private Product product; public Integer getName() { return name; } public void setName(Integer name) { this.name =3D name; } public Product getProduct() { return product; } public void setProduct(Product product) { this.product =3D product; } } It's pretty rough because I wrote it in gmail's email editor thing and I just woke up from a nap. You should get the point. On 5/8/06, suresh.dodda@wipro.com wrote: > > I have two classes : > > One is Product and other is Service. One product can have multiple > services. > > > > Product details are stored in product table. Service details in service > details. > > Service table has foreign key referencing prioduct_id which is primary ke= y > in product table. > > > > While doing select iBatis supports selecting data from multiple tables > using one query (avoiding N+1 selects). > > Is there a way to insert into multiple tables using one insert query. > > > > > > > > The information contained in this electronic message and any attachments > to this message are intended for the exclusive use of the addressee(s) an= d > may contain proprietary, confidential or privileged information. If you a= re > not the intended recipient, you should not disseminate, distribute or cop= y > this e-mail. Please notify the sender immediately and destroy all copies = of > this message and any attachments. > > WARNING: Computer viruses can be transmitted via email. The recipient > should check this email and any attachments for the presence of viruses. = The > company accepts no liability for any damage caused by any virus transmitt= ed > by this email. > > www.wipro.com > ------=_Part_23907_28283250.1147156537367 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline public class Product {
    private String name;
 =    private Integer id;

    public String ge= tName() {
        return name;
&nb= sp;   }

    public void setName(String name= ) {
        this.name =3D name;
    }

    p= ublic Integer getId() {
        retur= n id;
    }

    public void setId(I= nteger id) {
        this.id =3D id;
    }
}

public c= lass Service {
    private Integer name;
    private = Product product;

    public Integer getName() {
&n= bsp;       return name;
   = }

    public void setName(Integer name) {
 &= nbsp;      this.name =3D name;
    }

    public Pro= duct getProduct() {
        return pr= oduct;
    }

    public void setPro= duct(Product product) {
        this.= product =3D product;
    }
}

<sqlMap>
   <resultMap id=3D"ProductMap">
 &nb= sp;     <result property=3D"id" column=3D&= quot;id"/>
       <result prope= rty=3D"name" column=3D"name"
    <= resultMap id=3D"ServiceMap" class=3D"Service" groupBy= =3D"name">
       <result property=3D"produc= t" resultMap=3D"product" />
    &n= bsp;  <result property=3D"name" column=3D"name"= />
   </resultMap>
    <select i= d=3D"getAllServices" resultMap=3D"ServiceMap">
          select services.= *, products.* from services,product where services.product_id =3D  product.id
   </select><= br></sqlMap>
 

It's pretty rough because I wrote it in= gmail's email editor thing and I just woke up from a nap. You should get t= he point.
On 5/8/06, suresh.dodda@wipro.com= <suresh.dodda@wipro.com&g= t; wrote:

I have two classes :

One is Product and other is Service. One product can have multiple services.

 

Product details are stored in product table. Service details in service details.

Service table has foreign key referencing prioduct_id which is primary key in product table.

 

While doing select iBatis supports selecting data from multiple tables using one query (avoiding N+1 selects).

Is there a way to insert into multiple tables using one insert query.

 

 

 


The information contained in this electronic message and any attachments to= this message are intended for the exclusive use of the addressee(s) and ma= y contain proprietary, confidential or privileged information. If you are n= ot the intended recipient, you should not disseminate, distribute or copy t= his e-mail. Please notify the sender immediately and destroy all copies of = this message and any attachments.=20

WARNING: Computer viruses can be transmitted via email. The recipient shoul= d check this email and any attachments for the presence of viruses. The com= pany accepts no liability for any damage caused by any virus transmitted by= this email.

www.wipro.com

------=_Part_23907_28283250.1147156537367--