This article:  

    http://java.sun.com/j2se/1.3/docs/guide/jdbc/spec2/jdbc2.1.frame6.html

suggests that you can pass heterogeneous SQL statements to the database using 
the JDBC batch functionality.  However, it was less clear that you could do 
this with PreparedStatements.

Does iBATIS always use PreparedStatements even if there are no arguments to 
pass in?  In the examples you gave below, you didn't use arguments in your SQL 
statements.



From: [EMAIL PROTECTED]
To: [email protected]
Subject: RE: iBATIS and Batch
Date: Fri, 29 Feb 2008 14:31:28 -0700



















>> So
you group things together by table?





iBATIS doesn’t know what a table is.  It groups them by (Prepared)
SQL Statement.

 

>> Does
the JDBC driver not let you batch update across tables without changing the
order?

 

The batching features of JDBC are at the statement level.  We
maintain the order of the statements, but otherwise it’s exactly how the JDBC
documentation describes – which is quite vague and more up to the JDBC driver
than anything.  

 

I believe it’s as efficient as it can be, without losing the
order of the statements.

 

Clinton

 





From: Chris McMahon
[mailto:[EMAIL PROTECTED] 

Sent: February-29-08 2:07 PM

To: [email protected]

Subject: RE: iBATIS and Batch





 

So
you group things together by table?



Does the JDBC driver not let you batch update across tables without changing
the order?













From: [EMAIL PROTECTED]

To: [email protected]

Subject: RE: iBATIS and Batch

Date: Fri, 29 Feb 2008 11:53:39 -0700



It batches based on the statement.  So given this example:

 

INSERT INTO author (id,username, password, email, bio) VALUES
(1,'jim','********','[EMAIL PROTECTED]','');

INSERT INTO author (id,username, password, email, bio) VALUES
(2,'sally','********','[EMAIL PROTECTED]',null);

 

INSERT INTO blog (id,author_id,title) VALUES (1,1,'Jim
Business');

INSERT INTO blog (id,author_id,title) VALUES (2,2,'Bally Slog');

 

INSERT INTO post (id,blog_id,created_on,subject,body) VALUES
(1,1,'2007-12-05-00.00.00','Corn nuts','I think if I never smelled another corn
nut, it would be too soon...');

INSERT INTO post (id,blog_id,created_on,subject,body) VALUES
(2,1,'2008-01-12-00.00.00','Paul Hogan on Toy Dogs','That''s not a dog. 
THAT''s a dog!');

INSERT INTO post (id,blog_id,created_on,subject,body) VALUES
(3,2,'2007-12-05-00.00.00','Monster Trucks','I think monster trucks are
great...');

INSERT INTO post (id,blog_id,created_on,subject,body) VALUES
(4,2,'2008-01-12-00.00.00','Tea Parties','A tea party is no place to hold a
business meeting...');

 

These would be executed with 3 batches.  If you mix up the
order...

 

INSERT INTO author (id,username, password, email, bio) VALUES
(1,'jim','********','[EMAIL PROTECTED]','');

 

INSERT INTO blog (id,author_id,title) VALUES (1,1,'Jim
Business');

 

INSERT INTO post (id,blog_id,created_on,subject,body) VALUES
(1,1,'2007-12-05-00.00.00','Corn nuts','I think if I never smelled another corn
nut, it would be too soon...');

INSERT INTO post (id,blog_id,created_on,subject,body) VALUES
(2,1,'2008-01-12-00.00.00','Paul Hogan on Toy Dogs','That''s not a dog. 
THAT''s a dog!');

 

INSERT INTO author (id,username, password, email, bio) VALUES
(2,'sally','********','[EMAIL PROTECTED]',null);

 

INSERT INTO blog (id,author_id,title) VALUES (2,2,'Bally Slog');

 

INSERT INTO post (id,blog_id,created_on,subject,body) VALUES
(3,2,'2007-12-05-00.00.00','Monster Trucks','I think monster trucks are
great...');

INSERT INTO post (id,blog_id,created_on,subject,body) VALUES
(4,2,'2008-01-12-00.00.00','Tea Parties','A tea party is no place to hold a
business meeting...');

 

It would execute with 6 batches.

 

Doing it any other way would cause the statements to execute out
of order, which is a more serious concern and not correctable by the user of
the framework.

 

Clinton

 





From: Chris McMahon
[mailto:[EMAIL PROTECTED] 

Sent: February-29-08 11:43 AM

To: [email protected]

Subject: RE: iBATIS and Batch





 

We use the batch functionality
frequently.  How is iBATIS determining what is homogeneous and what is 
heterogeneous? 
We have a mix of both straight SQL updates and prepared statement updates.

 







From: [EMAIL PROTECTED]

To: [email protected]

Subject: RE: iBATIS and Batch

Date: Fri, 29 Feb 2008 08:58:43 -0700



Unfortunately no... that’s possibly something we can consider
for future versions.

 

The challenge is that some people have the exact opposite
problem.  They need the statements to maintain the order of
execution.  When initially deciding who to help, I decided that preserving
the order of execution was more important than performance.  I also
assumed that if you’re using a mixed order of heterogeneous statements, you
could probably find a way to order them by type and send them through to make
the most of batching.  Whereas the opposite wouldn’t be true, as if I
always just reordered the statements for the sake of performance – there would
be no way back.   I suppose we could support it as an option, but
before that I have to ask:

 

Can you reorder your statements?  If not, why not?

 

Clinton

 

 

 

 

 



From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 

Sent: February-29-08 8:47 AM

To: [email protected]

Subject: iBATIS and Batch



 



Recently
we have been implementing batched SQL calls using iBatis through JDBC. 



IT appears
that iBatis will reorganize batch statements into homogenous calls and treat
them as separate batches.... 



The
problem is that is if you do not serially add the homogenous statements, each
'change' from homogeneity results in a separate batch... 



Does
this sound correct?  Is there something we can do to control the batching
of heterogeneous calls?








Thank
you, 

Christopher



 







Connect
and share in new ways with Windows Live. Get it now!



 







Helping
your favorite cause is as easy as instant messaging. You IM, we give. Learn 
more.







_________________________________________________________________
Climb to the top of the charts! Play the word scramble challenge with star 
power.
http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_jan

Reply via email to