Saving entities problem
Saving entities problem
- Subject: Saving entities problem
- From: Jevon Hills <email@hidden>
- Date: Mon, 28 Jul 2003 10:21:25 -0600
I'm having problems saving new objects back to the database. I'm
assuming it probably has something to do with an EditingContext issue.
BACKGROUND: My company is switching from openbase to Sybase and I am in
the process of porting my applications. The problem I am having exists
in both databases, and I used to work in openbase. I don't know what
has changed.
I am using Sybase and WO 5.1
My application creates a handfull of new users and gives them all
permission to use an application in my system.
The database structure is 3 tables (Applications, Users, Permission)
[names are inconsistent due to database requirements], plus a 4th table
(UsersApplicationsPermissions) a link table for the 3 objects. In the
database the link table stores the three PrimaryKeys of the entities it
links.
I have 2 displayGroups one of Users and one of
UserApplicationPermissions.
My procedure:
I first create a new Users obj (Users aUsers = (Users)
dgUSERS.insertNewObjectAtIndex(users.count());) and give it a username
and password.
I then save the changes (
this.session().defaultEditingContext().saveChanges();)
**This works great in both databases currently
I then take each the user and using their obj plus the desired
application obj and permission obj ceate a new
UserApplicationPermission obj as follows
Permissions canUse; //assume this exists
Applications mlp; //assume this exists
//i insert a new UserApplicationPermission in displaygroup
USERAPPLICATIONPERMISSION at = (USERAPPLICATIONPERMISSION)
dgAppUserPerms.insertNewObjectAtIndex(aup.count());
And set it's values
at.setPermission(canUse);
at.setApplications(mlp);
at.setUsers(aUsers);
And then save the changes
again(this.session().defaultEditingContext().saveChanges();)
**This Does not work.
I am still new to inserting data into the database via WebObjects, and
I'm still grappling with editingContext and object graph, however.
btw. I have created the stored proc, and have the SyBase plugin
already and it seems to work.
I hope that I have provided the correct amount of information for
someone to point me in the right direction.
tia
Jevon K. Hills
Developer - Zymeta Media Promotion Systems
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.