ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Begin <clinton.be...@gmail.com>
Subject Re: Multiple Statements in one transaction/command
Date Wed, 02 Nov 2005 14:09:47 GMT
No, I would avoid that. I'm not sure what the appeal is of doing something
like this. More XML and less Java? I'm finding the opposite opinion is more
common these days....less XML and more Java. In fact, one of the highest
priority features of iBATIS 3.0 is XML-less iBATIS. ;-)

Cheers,
Clinton


On 10/26/05, H.E. Sum <hackitoergosum@yahoo.com> wrote:
>
> 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:
>
> (Pseudocode)
>
> AddUser(User) {
> [BeginTransaction]
> Mapper.Instance().Insert("InsertUser", user);
> foreach (Group in user.Groups) {
> Mapper.Instance().Insert("InsertGroup", group);
> }
> [CommitTransaction]
>
> 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 ...
> </insert>
> <foreach property="Groups">
> <insert id="InsertGroup">
> INSERT INTO group ...
> </insert>
> </foreach>
> </batchStatement>
>
> 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
> strategy?
>
> Thanks,
> H.E.
>
>
>
>
> __________________________________
> Yahoo! Mail - PC Magazine Editors' Choice 2005
> http://mail.yahoo.com
>

Mime
View raw message