• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: check whether a relationship is empty, efficiently
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: check whether a relationship is empty, efficiently


  • Subject: Re: check whether a relationship is empty, efficiently
  • From: Ramsey Gurley <email@hidden>
  • Date: Thu, 04 Feb 2016 10:29:25 -0700

I’ve done this before with a derived attribute to count to many relationship objects.

https://github.com/nullterminated/ponder/blob/master/ERR2d2w/Sources/er/r2d2w/ERR2d2w.java#L111

I was very green when I wrote that, so it’s sorta crappy. It doesn’t support compound FKs. Despite the comment, count(*) is not really MySQL specific. But it worked for me then. That allowed me to display (and sort) to many relationships as a count of objects in that relationship.

Derived counts only update on fetch, so they might be too stale in your case. You could also try a ERXExistsQualifier. That is sorta buggy, but it has worked for me in limited usage. It probably won’t be much help unless you use it in a fetch though. In memory, I suspect it just triggers a fault like anything else.

On Feb 3, 2016, at 6:34 PM, OC <email@hidden> wrote:

> Hello there,
>
> I'd bet this must be a WebObjects 101, but I can't see the best answer: is there an efficient way of checking whether an eo.someRelationship is empty?
>
> So far I simply check eo.someRelationship.count==0, but that might fire a fault, which is not exactly efficient if the only need is to know whether the relationship is empty or not.
>
> Of course I could rig myself something like “if already fetched in, simply check array count; if still fault, fetch max one object and see whether there's any...”, but this looks like a ubiquitous task enough it simply _must_ be done already (and in a far better way than I would do it myself)?
>
> Thanks for any advice,
> OC
>
>
> _______________________________________________
> 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


 _______________________________________________
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


References: 
 >check whether a relationship is empty, efficiently (From: OC <email@hidden>)

  • Prev by Date: Re: check whether a relationship is empty, efficiently
  • Next by Date: read-only binding
  • Previous by thread: Re: check whether a relationship is empty, efficiently
  • Next by thread: read-only binding
  • Index(es):
    • Date
    • Thread