Re: Enforcing a maximum cardinality on a many-to-many relationship
Re: Enforcing a maximum cardinality on a many-to-many relationship
- Subject: Re: Enforcing a maximum cardinality on a many-to-many relationship
- From: Chuck Hill <email@hidden>
- Date: Tue, 15 Aug 2017 07:14:26 +0000
- Thread-topic: Enforcing a maximum cardinality on a many-to-many relationship
Hi Paul,
For cases like this, the database is the right, and only, place to guarantee
this.
Chuck
From: Webobjects-dev
<webobjects-dev-bounces+chill=email@hidden> on behalf of Paul
Hoadley <email@hidden>
Date: Monday, August 14, 2017 at 7:11 PM
To: WebObjectsDev <email@hidden>
Subject: Enforcing a maximum cardinality on a many-to-many relationship
Hello,
I have EOs Job and Worker. Job.workers is a many-to-many relationship to
Worker, set up in the usual way, so there’s a JobWorker join table.
Job.maxWorkers is a mandatory Integer attribute whose value will be 1 or
greater.
I need to enforce a business rule such that Job.workers.count can never exceed
Job.maxWorkers. It’s sufficient that this is enforced at save-time: if a
particular in-memory Job has addToWorkersRelationship() called on it too many
times, I’m not too bothered, but it can’t be saved that way. Further, it needs
to be robust in the presence of multiple EOF stacks. (And although we use
JGroups synchronisation in deployment, assume that we don’t. The sync may not
happen fast enough.)
To me this sounds like a problem for database triggers: reject an insert on
JobWorker that would cause Job.workers.count to exceed Job.maxWorkers for the
referenced Job. Before I launch into that, though, does anyone know of (or can
anyone think of) a robust EOF-only solution to this problem?
--
Paul Hoadley
https://logicsquad.net/
https://www.linkedin.com/company/logic-squad/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden