• 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: EOAndQualifier on child entity property
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EOAndQualifier on child entity property


  • Subject: Re: EOAndQualifier on child entity property
  • From: Alexander Spohr <email@hidden>
  • Date: Sat, 19 Aug 2006 16:00:10 +0200

hello again,

for those of you who still did not get the problem, here is a thorough explanation of what yann tries to do, and why neither AND nor IN and even not a simple OR can fix yann's problem.

entities & relations:
A <-->> X <<--> B (B has attribute tag)

1.
if you do the join and then
(B.tag = 'green' AND B.tag = 'big')
you'll end up with no A's at all. B.tag in ONE ROW can be either 'green' OR 'big' but it can not be both.


2.
if you do the join and then
(B.tag = 'Green' OR B.tag = 'Big')
you'll get ALL A's that are either 'green' OR 'big' and the ones that are 'green' AND 'big'. the first group (green or big, but not both) is not wanted in the result.


3.
an IN is nothing but a shortened OR so it won't work, just like 2.


instead you have to do this, as Art was already writing:

select A.all
from A,X,B
where (A-X join and X-B join) AND (B.tag='green' OR B.tag='big')
GROUP BY A.pk
HAVING count(A.pk) = 2

that will only return those A's who connect to a green and a big B.


i extended the postgres-adaptor to allow this with a normal fetchspec.
you just drop some additional qualifiers and attributenames into the hints.
remember that you can only group by what you have in the result-set.


yann would do something like this:

// create fetchspec and hints
EOFetchSpecification aFetchSpec = new EOFetchSpecification("A", baseQualifier(), anOrderArray);
NSMutableDictionary aHintDict = new NSMutableDictionary();


// pick the attributes to group by
NSArray someAttributeNames = new NSArray(new String[] { "A_uniqueAttribute" })
aHintDict.setObjectForKey(someAttributeNames, PostgresqlExpression.GROUP_ATTRIBUTES_KEY);


// build the having-qualifier
EOKeyValueQualifier aHavingQualifier = new EOKeyValueQualifier ("A_uniqueAttribute", EOQualifier.QualifierOperatorEqual, new Integer (2));
aHintDict.setObjectForKey(aHavingQualifier, PostgresqlExpression.HAVING_QUALIFIER_KEY);


// set it all and fire
aFetchSpec.setHints(aHintDict);
aFetchSpec.setFetchLimit(1000);
NSArray anArray = anEdCon.objectsWithFetchSpecification(aFetchSpec);

and you might as well add some EOSortOrderings.

unfotunately he soes not use postgres, so i can't help him any further.
if there is some source for the mysql-adaptor i might dive into it and apply my modifications to it - if that’s possible at all.


have fun,
	atze

ps. i wonder why nobody else seems to need this? i use it at least for all statistics i run in my apps.


Am 19.08.2006 um 01:05 schrieb Chuck Hill:

I can see any problems in the code.  My three suggestions:

1. Check your model to ensure that all of attributes have names and column names

2. Try using another one like InSetQualifier. Not sure if that will work here, but I have had problems where one of these qualifiers would not work, but expressing it a different way in a different qualifier did work.

3.  Ask Pierre if he can help.  :-)

Chuck


On Aug 18, 2006, at 12:29 PM, Yann Bizeul wrote:

A safer bet is to use some extensions to WO. See Pierre Bernards excellent qualifier extensions at

http://www.bernard-web.com/pierre/webobjects/code.html

I tried that with the following code :

    public Main doFind()
    {
        Main nextPage = (Main)pageWithName("Main");

NSArray tags = NSArray.componentsSeparatedByString(tag," ");

NSMutableArray tagsQualifiers = new NSMutableArray();
int i;
for (i=0;i<tags.count();i++)
{
EOQualifier q = EOQualifier.qualifierWithQualifierFormat("tag = % @",new NSArray(tags.objectAtIndex(i)));
tagsQualifiers.addObject(new ExistsInRelationshipQualifier ("tags",q));
}
EOAndQualifier tagsQualifier = new EOAndQualifier(tagsQualifiers);

EOFetchSpecification f = new EOFetchSpecification ("Location",tagsQualifier,null);
nextPage.searchResults = session().defaultEditingContext ().objectsWithFetchSpecification(f);
return nextPage;
}



All I get is the following exception :
[2006-08-18 21:25:15 CEST] <WorkerThread0> java.lang.NullPointerException
at com.webobjects.eoaccess.EOSQLExpression._aliasForRelationshipPath (EOSQLExpression.java:324)
at com.webobjects.eoaccess.EOSQLExpression._aliasForRelatedAttributeRela tionshipPath(EOSQLExpression.java:259)
at com.houdah.webobjects.eoaccess.qualifiers.ExistsInRelationshipQualifi erSupport.sqlStringForSQLExpression (ExistsInRelationshipQualifierSupport.java:100)
at com.webobjects.eoaccess.EOQualifierSQLGeneration $Support._sqlStringForSQLExpression(EOQualifierSQLGeneration.java: 151)
at com.webobjects.eoaccess.EOSQLExpression.sqlStringForArrayOfQualifiers (EOSQLExpression.java:1562)
at com.webobjects.eoaccess.EOSQLExpression.sqlStringForConjoinedQualifie rs(EOSQLExpression.java:1597)
at com.webobjects.eoaccess.EOQualifierSQLGeneration $_AndQualifierSupport.sqlStringForSQLExpression (EOQualifierSQLGeneration.java:512)
at com.webobjects.eoaccess.EOQualifierSQLGeneration $Support._sqlStringForSQLExpression(EOQualifierSQLGeneration.java: 151)
at com.webobjects.eoaccess.EOSQLExpression.sqlStringForArrayOfQualifiers (EOSQLExpression.java:1562)
at com.webobjects.eoaccess.EOSQLExpression.sqlStringForConjoinedQualifie rs(EOSQLExpression.java:1597)
at com.webobjects.eoaccess.EOQualifierSQLGeneration $_AndQualifierSupport.sqlStringForSQLExpression (EOQualifierSQLGeneration.java:512)
at com.webobjects.eoaccess.EOQualifierSQLGeneration $Support._sqlStringForSQLExpression(EOQualifierSQLGeneration.java: 151)
at com.webobjects.eoaccess.EOSQLExpression.prepareSelectExpressionWithAt tributes(EOSQLExpression.java:1024)
at com.webobjects.jdbcadaptor.JDBCExpression.prepareSelectExpressionWith Attributes(JDBCExpression.java:273)
at com.webobjects.eoaccess.EOSQLExpressionFactory.selectStatementForAttr ibutes(EOSQLExpressionFactory.java:226)
at com.webobjects.jdbcadaptor.JDBCChannel.selectAttributes (JDBCChannel.java:178)
at com.webobjects.eoaccess.EODatabaseChannel._selectWithFetchSpecificati onEditingContext(EODatabaseChannel.java:878)
at com.webobjects.eoaccess.EODatabaseChannel.selectObjectsWithFetchSpeci fication(EODatabaseChannel.java:215)
at com.webobjects.eoaccess.EODatabaseContext._objectsWithFetchSpecificat ionEditingContext(EODatabaseContext.java:3205)
at com.webobjects.eoaccess.EODatabaseContext.objectsWithFetchSpecificati on(EODatabaseContext.java:3346)
at com.webobjects.eocontrol.EOObjectStoreCoordinator.objectsWithFetchSpe cification(EOObjectStoreCoordinator.java:539)
at com.webobjects.eocontrol.EOEditingContext.objectsWithFetchSpecificati on(EOEditingContext.java:4114)
at com.webobjects.eocontrol.EOEditingContext.objectsWithFetchSpecificati on(EOEditingContext.java:4500)
at FindRightComponent.doFind(FindRightComponent.java:36)


Yann Bizeul • yann at tynsoe.org
Cocoa Developer



--

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems. http://www.global-village.net/products/ practical_webobjects





_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40freeport.de


This email sent to email@hidden

Freeport & Soliversum Alexander Spohr email@hidden www.freeport.de


_______________________________________________ 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
  • Follow-Ups:
    • Re: EOAndQualifier on child entity property
      • From: James Cicenia <email@hidden>
References: 
 >EOAndQualifier on child entity property (From: Yann Bizeul <email@hidden>)
 >Re: EOAndQualifier on child entity property (From: Sacha Michel Mallais <email@hidden>)
 >Re: EOAndQualifier on child entity property (From: Chuck Hill <email@hidden>)
 >Re: EOAndQualifier on child entity property (From: Yann Bizeul <email@hidden>)
 >Re: EOAndQualifier on child entity property (From: Chuck Hill <email@hidden>)

  • Prev by Date: help with mysql
  • Next by Date: Re: EOAndQualifier on child entity property
  • Previous by thread: Re: EOAndQualifier on child entity property
  • Next by thread: Re: EOAndQualifier on child entity property
  • Index(es):
    • Date
    • Thread