Raw Rows and SUM(...) Issue with Joins and MySQL
Raw Rows and SUM(...) Issue with Joins and MySQL
- Subject: Raw Rows and SUM(...) Issue with Joins and MySQL
- From: email@hidden
- Date: Tue, 25 Apr 2006 18:28:28 +1200
Hello;
At runtime, I'm adding an attribute to an entity to get a SQL "SUM()"
operation to occur. The read format is "SUM(%P)". I add this
attribute, fetch it as a raw row and then remove the attribute. This
has been working rather well for some years, but I have a wee
specific problem with it now. I am modeling an inheritance
arrangement, but I'm *NOT* using EOF's inheritance support...
Rucksack ]--- Bag (one to many)
Handbag ]---- Bag (one to many)
Wallet ]----- Bag (one to many)
{"Rucksack","Handbag","Wallet"} are essentially specialisations of
"Bag" and are treated in code as one-to-one despite being data
modelled as one-to-many. So I go ahead and make a fetch spec like
this...
EOFetchSpecification fs = new EOFetchSpecification(
"Rucksack",
(<eg: rucksackColour = "green">)
null)
bagEntity.addAttribute(<<my attr called "calc" which ends up being
SUM(price)>>)
fs.setFetchesRawRows(true);
fs.setRawRowKeyPaths(new NSArray("bag.calc"));
result = ec.objectsWithFetchSpecification(fs);
The SQL that gets generated looks like this:
SELECT SUM(T1.price), t0.bagid FROM rucksack t0, bag T1 WHERE ....
The problematic part for me is the "t0.bagid" select item as this
does not work against MySQL because it wants grouping to occur. I'm
not sure how this extra select item gets in there, but must be the
result of EOF figuring out how to make the join work. I would
ideally like to stop this extra select item appearing. Any
suggestions? I was previously using EODatabaseContext and channels
and stuff manually, but this proved too tricky to achieve the
'automated join generation' at the same time.
cheers.
___
Andrew Lindesay
www.lindesay.co.nz
_______________________________________________
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