Mailing List webobjects-dev@wocommunity.org Message #487
From: Ramsey Gurley <Ramsey.Gurley@practicemojo.com>
Subject: Re: [WO-DEV] Ideas for arbitrary to-one associations
Date: Mon, 15 Jan 2024 23:31:39 +0000
To: WebObjects & WOnder Development <webobjects-dev@wocommunity.org>
If you're starting from scratch, you could do this using vertical inheritance. You're sorta inventing your own vertical inheritance doing what you describe, but the entity name is on the note table instead of on the entity table. What you would do is have one super class 'Notable' EO with a 'notes' to-many, and all the things you want to have related notes would subclass it.

However, that's not going to work if you already have existing EOs with PK collisions in different tables. Vertical inheritance is also the lowest performance inheritance, because it needs to do the extra joins. But on the upside, you could benefit from EOF knowing how to do shallow vs deep fetches against such an entity.

It sounds like you want graph database features in a relational database. If you think you will need more tables like this note table, you could create a join table to hold all the messiness. Similar to an EOF many-to-many, you would have compound PK made of FKs to two tables, but you would add two more entity identifier columns, one for each FK. This would allow you to apply the same sort of anything to anything relations to all tables.


From: WebObjects & WOnder Development on behalf of Markus Ruggiero (rucotec)
Sent: Monday, January 15, 2024 9:45 PM
To: WebObjects & WOnder Development
Subject: [WO-DEV] Ideas for arbitrary to-one associations

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---


Confidentiality Notice: This email, including all attachments and replies thereto, are covered by the Electronic Communications Privacy Act, 18 U.S.C. Sections 2510-2521 and are legally privileged. This information is confidential, and intended only for the use of the individuals or entities named above. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or the taking of any action in reliance on the contents of this transmitted information is strictly prohibited. Please notify us if you have received this transmission in error. Thank you.
Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to Listmaster