ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Maves <Nathan.Ma...@Sun.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:37:48 GMT
While some of the drivers might support multiple statements I would  
suggest against it.

I would write this into the DAO level of your code.

something like....

public void insertProduct(Product p) {
   startTransaction();
   executeInstert("insertProduct", p);
   for(Service s:p.getServices()) {
     executeInsert("insertService", s);
   }
   commitTransaction();
  .....
}

Not perfect but you get the picture :)

Nathan
On May 8, 2006, at 11:07 PM, 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