Hi!

I'm trying to solve a weird problem. Let's say I have entity A that has a to-many relationships to an entity B. Entity B has a boolean attribute called "status".

I need to run a fetch specification on A with some trivial stuff, but I need the values to be sorted according to B's status. Particularly, I want all A's that have at least one B with status set to true to come before the A's with all the B's with status set to false, or A's that have no B's. Also, for each "group" of A's I want to use a second sorting criteria using one of the A's attributes, which shouldn't be a problem.

My problem is how to create this sort ordering based on the fact that at least one B has status set to true. Doing this in memory is trivial, but on the database is a pain. I thought in two approaches:

1) Create a derived column in the database, and create a read-only attribute in the model. The problem is that PostgreSQL seems unable to create a derived column on a real table. It will only work in views.

2) Creating a derived attribute and using it to the sort ordering. I know that, contrarily to what might seem true, EOF can actually run fetch specs over derived attributes. But I don't know:

a) How to create such derived attribute. This is a little more complex than the typical MONTHLY_SALARY * 12 example, and
    b) Would EOF be able to use that on a sort ordering.

There is an obvious third approach that is creating an attribute in A that is true if any of the B's status are true, but that's ugly for so many reasons.

  Any ideas?

  Yours

Miguel Arroz

http://www.survs.com

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to