Mailing List webobjects-dev@wocommunity.org Message #485
From: Markus Ruggiero (rucotec) <markus.ruggiero@rucotec.ch>
Subject: Ideas for arbitrary to-one associations
Date: Mon, 15 Jan 2024 13:45:45 +0100
To: WebObjects & WOnder Development <webobjects-dev@wocommunity.org>
Signed Data (Text SHA256)
I am looking for ideas / strategies to implement the following requirement:

I want to implement something I call GeneralNote. It should be possible to create such a note anywhere in the application and associate it with the current EO, whatever this may be. Thus any EO can potentially have 0 to many GeneralNote objects hanging off it. One GeneralNote however is not shared, thus it is a real to-one relationship from GeneralNote to an EO.
It is obviously not possible (well, more like totally impractical) to model a to-one relationship from GeneralNote to any/all possible destination entities in my EOModel.

Any ideas on how to do this? I want to leverage as much as possible the power of EOF. I was experimenting with code that puts the destination entity and the destination object’s primary key value in attributes of GeneralNote. I also have code that can find GlobalNote objects for an EO by using its entity name and primary key for fetching. All our EOs share a common base class that can easily accommodate such code generically. But what if the EO and a note is created at the same time? There is no primary key value yet! And how can I prevent an EO from being deleted and leaving orphaned notes behind? Would overriding willDelete() be a good place to also delete the notes? What about not allowing EO deletion when there still are notes?

Thanks for any ideas!
---markus---

Content Unaltered as verified By:
<markus.ruggiero@rucotec.ch>
Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to Listmaster