ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "H.E. Sum" <hackitoergo...@yahoo.com>
Subject Multiple Statements in one transaction/command
Date Thu, 27 Oct 2005 02:34:46 GMT
What's a good pattern to perform multiple statements
on a single DAO method. Suppose I have a bunch of
"User" objects each containing a list of "Group"
objects. Right now I'm doing the following:


AddUser(User) {
   Mapper.Instance().Insert("InsertUser", user);
   foreach (Group in user.Groups) {
      Mapper.Instance().Insert("InsertGroup", group);

Is there a way to move this type of transaction to
iBatis. I'm thinking along the lines of a hypothetical
construct like:

<batchStatement id="InsertUserAndGroups"
useTransaction="true" parameterClass="User">
   <insert id="InsertUser">
      INSERT INTO user ...
   <foreach property="Groups">
      <insert id="InsertGroup">
          INSERT INTO group ...

In the example, the <insert> statements are the same
as usual except they implicitly take the parameter
specified in the <batchStatement> tag.

Is there something like this already in iBatis or
planned for the future, or is this a misguided


Yahoo! Mail - PC Magazine Editors' Choice 2005 

View raw message