ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: Best way to handle large transactions?
Date Sat, 14 Jan 2006 03:44:30 GMT
IBatisNet.DataMapper.Mapper.Instance().BeginTransaction();
try
{
foreach (collection of students){
    Student AStudent = Student.Find(someid);
    AStudent.Active = true;
    AStudent.Save();
    foreach (collection of data) {
       TopicSection ts = new TopicSection();
       ts.Property1 = "some value";
       ts.Property2 = "some value";
       ts.Save();
    }
}
IBatisNet.DataMapper.Mapper.Instance().CommitTransaction();
}
catch
{
IBatisNet.DataMapper.Mapper.Instance().RollBackTransaction();
throw;
}

----- Original Message ----
From: Shawn Smiley <ssmiley483@yahoo.com>
To: iBatis Users <user-cs@ibatis.apache.org>
Sent: Tuesday, January 10, 2006 4:28:33 PM
Subject: Best way to handle large transactions?


 I have a data import routine that needs to do approximately 500 or so inserts/updates across
6 tables in a SQL Server database within a single transaction (all succeed or all fail).

What is the best way to handle this in iBatis?

This is an ASP.net 1.1 application and I have a 1:1 mapping between iBatis DAL objects and
tables in the database.

Related to the above, are there any good examples out there on how to properly do transactions
with iBatis?


Roughly what I have for code (not currently using a transaction) is something like this (psudocode):
Visit TargetVisit = Visit.Find(1234);
TargetVisit.Status = VisitStatuses.Completed;
TargetVisit.Save();

foreach (collection of students){
    Student AStudent = Student.Find(someid);
    AStudent.Active = true;
    AStudent.Save();
    foreach (collection of data) {
       TopicSection ts = new TopicSection();
       ts.Property1 = "some value";
       ts.Property2 = "some value";
       ts.Save();

       ... This continues down 3 more tables...
    }
}


Thanks for any suggestions on the best way to put this into a single transaction.

-Shawn



Yahoo! Photos Showcase holiday pictures in hardcover
Photo Books. You design it and well bind it!
Mime
View raw message