Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 3606 invoked from network); 13 Dec 2005 21:25:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 Dec 2005 21:25:21 -0000 Received: (qmail 87090 invoked by uid 500); 13 Dec 2005 21:25:18 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 87075 invoked by uid 500); 13 Dec 2005 21:25:18 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 87058 invoked by uid 99); 13 Dec 2005 21:25:18 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Dec 2005 13:25:18 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [206.219.199.36] (HELO dalsmtpmx01.parsons.com) (206.219.199.36) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Dec 2005 13:25:16 -0800 Received: from dalimss01.Parsons.com (dalimss01.parsons.com [172.21.212.38]) by dalsmtpmx01.parsons.com (8.12.11/8.12.11) with ESMTP id jBDLRQWs024546 for ; Tue, 13 Dec 2005 15:27:26 -0600 Received: from exchdalims0103.Parsons.com ([172.21.212.41]) by dalimss01.Parsons.com with InterScan Messaging Security Suite; Tue, 13 Dec 2005 15:24:54 -0600 Received: from exchdal04.Parsons.com ([172.21.212.19]) by exchdalims0103.Parsons.com with Microsoft SMTPSVC(6.0.3790.211); Tue, 13 Dec 2005 15:24:54 -0600 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: RE: Multiple table insert problem. Date: Tue, 13 Dec 2005 15:24:54 -0600 Message-ID: <2F038EED15EF804A84175613FD39FA420241B9@exchdal04.Parsons.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Multiple table insert problem. Thread-Index: AcYAKpQSsxLQkgrVSaarI8xnyM+7+QACQ/aQ From: "Vu, Thai" To: X-OriginalArrivalTime: 13 Dec 2005 21:24:54.0656 (UTC) FILETIME=[A90EF000:01C6002B] X-imss-version: 2.012 X-imss-result: Passed X-imss-scores: Clean:99.90000 C:17 M:2 S:5 R:5 X-imss-settings: Baseline:1 C:1 M:1 S:1 R:1 (0.0000 0.0000) X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N By the way, I'd like to ask some questions. - Is there any iBATIS example about calling an Oracle stored procedure which returns a reference cursor? - When I call a stored procedure, can I use a normal bean class instead of a map (e.g. HashMap) for the tag? I think I can answer this question by trying both cases, but I'd also like to ask it here in case I fail in both cases. Sincerely, Thai -----Original Message----- From: Albert L. Sapp [mailto:asapp@uiuc.edu]=20 Sent: Tuesday, December 13, 2005 3:17 PM To: user-java@ibatis.apache.org Subject: Re: Multiple table insert problem. Larry Meadors wrote: >Why not just simplify your life and make it a stored procedure? > >Larry > > >On 12/13/05, Albert L. Sapp wrote: > =20 > >>Hi, all. >> >>Our project has been going along well with iBatis and we have already >>rolled out 5 of 7 modules. They like us to automate as much as possible >>and not have the users going to multiple screens to do something, so >>that is where we ran into the problem. >> >>This is for a Oracle database and I am learning PL/SQL and SQL as I >>build this application, so I don't know if there is something in PL/SQL >>or SQL that would do this and not in iBatis. I have been doing searches >>to see if anyone has an example of how to do this in PL/SQL or SQL, but >>apparently I am not searching correctly. >> >>When I create a group, I want to create entries in multiple tables. A >>entry in the group table, a entry for the group's leader in a group >>member table, a entry for the group leader in the user roles table >>indicating he has the group administrator role and, finally, another >>entry in the user roles table if a backup group administrator is entered >>at group creation time. >> >>This is the bean that I pass to the insert function. >> >> =20 >> >>>public class GroupCreate extends BaseBean implements TransferObject >>>{ >>> static final long serialVersionUID =3D 0; >>> >>> private Group group; >>> private UserGroup userGroup; >>> private UserRole userRole1; >>> private UserRole userRole2; >>> >>> public GroupCreate() >>> { >>> group =3D null; >>> userGroup =3D null; >>> userRole1 =3D null; >>> userRole2 =3D null; >>> } >>> >>> public GroupCreate(Group group, UserGroup userGroup, UserRole >>>userRole1, UserRole userRole2) >>> { >>> this.group =3D group; >>> this.userGroup =3D userGroup; >>> this.userRole1 =3D userRole1; >>> this.userRole2 =3D userRole2; >>> } >>> >>> public Group getGroup() >>> { >>> return group; >>> } >>> >>> public void setGroup(Group group) >>> { >>> this.group =3D group; >>> } >>> >>> public UserGroup getUserGroup() >>> { >>> return userGroup; >>> } >>> >>> public void setUserGroup(UserGroup userGroup) >>> { >>> this.userGroup =3D userGroup; >>> } >>> >>> public UserRole getUserRole1() >>> { >>> return userRole1; >>> } >>> >>> public void setUserRole1(UserRole userRole1) >>> { >>> this.userRole1 =3D userRole1; >>> } >>> >>> public UserRole getUserRole2() >>> { >>> return userRole2; >>> } >>> >>> public void setUserRole2(UserRole userRole2) >>> { >>> this.userRole2 =3D userRole2; >>> } >>>} >>> =20 >>> >>In the group.xml, I have the following defined. >> >> =20 >> >>>>>parameterClass=3D"scs.reaction.user.beans.GroupCreate"> >>> BEGIN >>> INSERT INTO REACTION_USERS.GROUPS (GROUP_ID, >>> GROUP_LEADER_ID, >>> GROUP_NAME, >>> DESCRIPTION, >>> CREATED_BY, >>> CREATED_ON, >>> MODIFIED_BY, >>> MODIFIED_ON, >>> CON_CHECK, >>> GROUP_ADMINISTRATOR) >>> VALUES (#group.groupID:BIGINT#, >>> #group.groupLeaderID:BIGINT#, >>> #group.groupName:VARCHAR#, >>> #group.description:VARCHAR#, >>> #group.createdBy:BIGINT#, >>> #group.createdOn:TIMESTAMP#, >>> #group.modifiedBy:BIGINT#, >>> #group.modifiedOn:TIMESTAMP#, >>> #group.conCheck:BIGINT#, >>> #group.groupAdministrator:BIGINT#); >>> INSERT INTO REACTION_USERS.USER_GROUPS (USER_GROUP_ID, >>> USER_ID, >>> GROUP_ID, >>> MEMBERSHIP_STATUS, >>> CON_CHECK) >>> VALUES >>>(#userGroup.userGroupID:BIGINT#, >>> #userGroup.userID:BIGINT#, >>> #userGroup.groupID:BIGINT#, >>> >>>#userGroup.membershipStatus:VARCHAR#, >>> #userGroup.conCheck:BIGINT#); >>> INSERT INTO REACTION_USERS.USER_ROLES (USER_ROLE_ID, >>> USER_ID, >>> ROLE_ID, >>> NETID, >>> ROLE) >>> VALUES (#userRole1.userRoleID:BIGINT#, >>> #userRole1.userID:BIGINT#, >>> #userRole1.roleID:BIGINT#, >>> #userRole1.netID:VARCHAR#, >>> #userRole1.role:VARCHAR#); >>> INSERT INTO REACTION_USERS.USER_ROLES (USER_ROLE_ID, >>> USER_ID, >>> ROLE_ID, >>> NETID, >>> ROLE) >>> VALUES (#userRole2.userRoleID:BIGINT#, >>> #userRole2.userID:BIGINT#, >>> #userRole2.roleID:BIGINT#, >>> #userRole2.netID:VARCHAR#, >>> #userRole2.role:VARCHAR#); >>> END; >>> >>> =20 >>> >>This works if a backup group administrator is defined when the group is >>defined. Otherwise, the last insert will fail because of null values. >>Is there a way I can set this up to not do the last insert if the >>userRole2 is null, but do it otherwise? I don't want to set up a >>seperate id=3D"GroupInsertNoBackup" and another bean that does not = have >>userRole2 in it. >> >>Thanks for any help or pointers you can give me. >> >>Al >> >> =20 >> > > =20 > I think that may be the only way to do it. It will take a while to=20 learn to write a Oracle stored procedure to do what I want it to do,=20 then to write a call to the stored procedure. I have never done either=20 before. Always something new to learn. Thanks for the suggestion. Al