Hi Robert, ----- Original Message ----- From: "Robert S. Sfeir" <[EMAIL PROTECTED]> To: "OJB Users List" <[EMAIL PROTECTED]> Sent: Thursday, February 20, 2003 11:18 PM Subject: Re: auto-update, auto-delete set dynamically?
> Thomas, > > I get this: > > PersistenceBroker broker = null; > broker = PersistenceBrokerFactory.defaultPersistenceBroker(); > ClassDescriptor cd = broker.getClassDescriptor( HomeBO.class ); > ObjectReferenceDescriptor ord = > cd.getObjectReferenceDescriptorByName(???);//??? because there is no > explanation in the API as to WHICH name we need to use. > ord.setCascadeRetrieve(false); > > The question is that if I'm using ODMG and I open my DB with: > > ... > > db = odmg.newDatabase(); > db.open( DBC , Database.OPEN_READ_WRITE ); > > ... > > will the PersistenceBrokerFactory.defaultPersistenceBroker(); return > anything at all? An alternative way is to use the MetadataManager: MetadataManager mm = MetadataManager.getInstance(); ClassDescriptor cld = mm.getDescriptorRepository().getDescriptorFor(Class c); With the MM it's also possible to do only 'per thread' changes of metadata. Your solution do a global change, thus other threads 'see' your modifications too. See javadoc for MM (In CVS you could find a enhanced version of MM with better javadoc and some new methods). More about the new methods http://archives.apache.org/eyebrowse/ReadMsg?[EMAIL PROTECTED] pache.org&msgNo=5527 > > Second where I have the ??? the API has no documentation on what String > value it's looking for (name has not description), but from the > description of the class I'm guessing that it wants to know WHICH > reference of the foreign-key who's attribute I want to assign to ord > and then set its Cascade type to false... Is that correct??? > > I obviously haven't tested this yet so... > > If my assumptions above are all correct, then my feature request for > future version is to have a method which can apply Cascade types across > the board for the whole ClassDescriptor and its related classes. I > think the way you have above is fine for now, but can be quite > cumbersome on tables with a lot of inverse foreign keys. (that's > assuming I understood where you were sending me) > > The reason I want to do this is, by the way, is because based on the > user role in the application, I want to have the select update and > delete behave different ways. For example if the user's role is DBA, > then I want everything on and allow the DBA to cascade a delete if they > want to, but if it's Joe User, then I don't even want to give them that > option and have the default set to no in the repository files. Maybe we should enhance the MM to support different repository profiles, e.g. you could add a 'user' profile and a 'admin' profile. Then it would be possible to use MM.loadProfile(String profileName, boolean global); What do you think? regards, Armin > > R > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]