Following on from that question, I have one other design issue.... I map patients to local health organisations using their postcode (zipcode). I have a third-party sourced table with two columns: postcode and organisation id. Both are unique but have business meaning. At present, I am using the string postcode and string organisation id as primary keys.
A user can complete an address for a patient, and types in the postcode. At the moment, I have a relationship defined with the text entered by the user as a foreign key acting as a lookup. I don't mind if the postcode doesn't exist as it may be a new postcode. I can therefore say: patient.currentAddress.postcode.localHealthBoard.name and get the name of the health organisation for that patient. As you can imagine, there are quite a few postcodes in the UK. I've therefore used a one-way relationship to avoid excessive fetches. However, this isn't working - WO complains about not having a null relationship - presumably because I've sneaked in behind EOF's back and set the foreign key directly. Solutions? 1. Instead of a relationship, perform a manual lookup when the postcode is entered and then set the relationship directly in the proper way (addBothSides...). Problem then is keeping items in sync and making sure that when the postcode is changed the relationship is updated. In particular, health organisation changes may change the mapping of postcodes to organisations - using a relationship keyed to postcode will magically update. Manual lookup won't do that. Plus: when to do manual lookup - during an action - when the mapping table is updated? what if there are several components that need this.... 2. Somehow set the relationship just before the ec.saveChanges() step - but I know I'm not allowed to do that during validateForSave() - when can I do it? Can I hook into the object lifecycle? I've read Chap 3 of Practical Webobjects and see one method there for notifications. 3. Am I missing a simpler method? Many thanks, and apologies for the (rather) specific questions... -- Dr. Mark Wardle Specialist registrar, Neurology Cardiff, UK _______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
