You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Grim Shieldsson <gr...@yahoo.com> on 2003/07/02 01:05:35 UTC

Update problems with ODMG and 1:N

I'm writing a web application, and trying to get users and roles in the
database.  So I have a User and Role table/objects, where of course A
user can have multple roles.
I decided that I really didn't want to have the web page modifying the
user/role objects inside a transaction, since this is a web
application.  So I get the user info, find out what modifications to
the roles list they want, and then make the modifications.
So my update method looks like this:

...
public void update( User user) {
...
//Get the user from the database code as toBeEdited
...
toBeEdited.setRoles( user.getRoles);
tx.commit();
...
}
Roles are DLists, however the DB does not get updated.

Then I tried:
...
public void update( User user) {
...
//Get the user from the database code as toBeEdited
...
toBeEdited.getRoles().clear();
Iterator iterator = user.getRoles().iterator();
while( iterator.hasNext()) {
  toBeEdited.getRoles().add( iterator.next());
}

tx.commit();
...
}

But that doesn't work either.  Oddly enough using just the clear
doesn't work either.  Clear empties the DList, but does NOT do anything
to the database.
I then tried to individually remove each role, and then add the new
ones back.  No luck there either.
I'm trying to avoid having to do some sort of synchronizing between the
two different roles.  I'd like to just be able to delete the old roles,
and add the new ones in it's place.... any ideas?

Or is there a better way to do what I want?



__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com