ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jerome Gagner" <phpmon...@gmail.com>
Subject Re: I am new to iBatis. Is it possible to insert into multiple tables using one parameter class using iBatis
Date Tue, 09 May 2006 06:45:00 GMT
hahah disregard that, didn't really answer the question. Just like I said, I
just woke up.


On 5/8/06, Jerome Gagner <phpmonkey@gmail.com> wrote:
>
> public class Product {
>     private String name;
>     private Integer id;
>
>     public String getName() {
>         return name;
>     }
>
>     public void setName(String name) {
>         this.name = name;
>     }
>
>     public Integer getId() {
>         return id;
>     }
>
>     public void setId(Integer id) {
>         this.id = id;
>     }
> }
>
> public class Service {
>     private Integer name;
>     private Product product;
>
>     public Integer getName() {
>         return name;
>     }
>
>     public void setName(Integer name) {
>         this.name = name;
>     }
>
>     public Product getProduct() {
>         return product;
>     }
>
>     public void setProduct(Product product) {
>         this.product = product;
>     }
> }
>
> <sqlMap>
>    <resultMap id="ProductMap">
>        <result property="id" column="id"/>
>        <result property="name" column="name"
>     <resultMap id="ServiceMap" class="Service" groupBy="name">
>        <result property="product" resultMap="product" />
>        <result property="name" column="name"/>
>    </resultMap>
>     <select id="getAllServices" resultMap="ServiceMap">
>           select services.*, products.* from services,product where
> services.product_id =  product.id
>    </select>
> </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 the point.
>
> On 5/8/06, suresh.dodda@wipro.com <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
> > 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
> > may contain proprietary, confidential or privileged information. If you are
> > not the intended recipient, you should not disseminate, distribute or copy
> > 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 transmitted
> > by this email.
> >
> > www.wipro.com
> >
>
>

Mime
View raw message