On Jul 13, 2009, at 6:50 AM, Gustavo Pizano wrote:

Hello I have been thinking a while on the following qualifier..

I have the following db schema.

Thinking in terms of DB schema is going to be an obstacle to effectively grasping EOF and using it to your fullest potential. I only think about this level if I am optimizing. Think about the model, the relationships, and Java objects.


I need to fetch all WG that  has in TRANSLATIONSET a specific userID.

Think: I need to find all the WG where wg.translationSets().users() contains a specific user. Or I need to find all the WG where wg.translationSets() contains the TranslationSet where translationSet.users() contains a specific user. Or, breaking it down more, I need to find all the TranslationSets where translationSet.users() contains a specific user, then I need to find all the WG where wg.translationSets() contains one of those TranslationSets


but so far what I have from the user is the name... so I will need to get the userID something like toUser.NAME.eq(name).

any ideas?

Break it down (I will use the syntax that I have been using as I have not started using ERXKey, yeah, yeah, I know):

1. Find the User
ERXQ.equals(User.NAME, name)


2. Find the TranslationSet
ERXQ.contains(TranslationSet.USERS, user)
* this contains might not work for all databases

3. Find the WG
OK. This gets a bit trickers. Time to break out the Wonder qualifiers in er.extensions.eof.qualifiers. If those let you down, there are more in the Houdah framework. Sometimes you have to play with these to find one that works / generates the SQL you want.

ERXExistsQualifier looks promising

EOQualifier tsQual = new ERXExistsQualifier(ERXQ.equals(User.NAME, name),
                                                                    
TranslationSet.USERS);

EOQualifier qual = new ERXExistsQualifier(tsQual, WG.TRANSLATIONSETS);


ERXQualifierInSubquery might work too
EOQualifier qual = new ERXExistsQualifier(tsQual, TRANSLATIONSETS.ENTITY_NAME, WG.TRANSLATIONSETS);


No guarantee that either of those will work, but that is the direction to look in.


Chuck



Attachment: DBSchemainPDF.pdf
Description: Adobe PDF document


--
Chuck Hill             Senior Consultant / VP Development

Learn WO at WOWODC'09 East in Montréal this August!
http://www.wocommunity.org/wowodc09/east

http://arstechnica.com/apple/news/2009/07/webobjects-sliced-from-106but-prognosis-of-death-premature.ars

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
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