Re: Query on relationship to abstract entity failing w/horizontal inheritance
Re: Query on relationship to abstract entity failing w/horizontal inheritance
- Subject: Re: Query on relationship to abstract entity failing w/horizontal inheritance
- From: Ken Anderson <email@hidden>
- Date: Wed, 07 Feb 2007 17:14:26 -0500
I'm using Sybase... but I'm pretty sure I'm using the regular JDBC
connector. Thanks for the hints!
Ken
On Feb 7, 2007, at 11:38 AM, Alexander Spohr wrote:
Hi,
What database are you using? I fixed that for PostgreSQLPlugin but
had no time so far to push it back to the svn.
if (bEntity.isAbstractEntity())
{
NSArray anExternalNameArray = (NSArray) entity.subEntities
().valueForKey("externalName");
aBuffer.append(" (" + anExternalNameArray.componentsJoinedByString
(" NATURAL FULL OUTER JOIN ") + ")");
}
It did work in the past - at least with the Oracle-adaptor I rember
it to work.
atze
ps. I added GROUP BY HAVING, aliases and formatted attributes as
well. If someone is interested....
Heres part of my code:
/**
* Overridden because the original version does not correctly
quote mixed case table names in all cases.
* SELECT statements were OK (useAliases is true) INSERT,
UPDATE, DELETE didn't quote mixed case field names.
* 20060712 atze: added fetching of abstract entities (was
impossible before).
*
* @return the SQL string for the table names
*/
public String tableListWithRootEntity(EOEntity entity) {
if (useAliases())
{
// atze: can we make this faster?
NSDictionary aDict = aliasesByRelationshipPath();
Enumeration aKeyEnum = aDict.keyEnumerator();
StringBuffer aBuffer = new StringBuffer();
while (aKeyEnum.hasMoreElements())
{
EOEntity bEntity = entity;
String aKey = (String) aKeyEnum.nextElement();
NSArray anArray = NSArray.componentsSeparatedByString(aKey,
"."); // split the path
for (int i = 0; i < anArray.count(); i++)
{
EORelationship aRS = bEntity.relationshipNamed((String)
anArray.objectAtIndex(i));
bEntity = aRS.destinationEntity();
}
if (bEntity.isAbstractEntity())
{
NSArray anExternalNameArray = (NSArray) entity.subEntities
().valueForKey("externalName");
aBuffer.append(" (" +
anExternalNameArray.componentsJoinedByString(" NATURAL FULL OUTER
JOIN ") + ")");
}
else
{
aBuffer.append(bEntity.externalName());
}
if (useAliases())
aBuffer.append(" " + (String) aDict.objectForKey(aKey));
if (aKeyEnum.hasMoreElements())
aBuffer.append(",");
}
return aBuffer.toString();
// return super.tableListWithRootEntity(anEntity);
}
return entity.valueForSQLExpression(this);
}
Am 06.02.2007 um 16:54 schrieb Ken Anderson:
Everyone,
I swear this has worked in the past - if I'm mistaken, please
remind me!
I have an entity (MemberRuleField) with a relationship to an
abstract entity (MemberRule). MemberRule (and it's sub-entities)
has a relationship called MemberCompanyRole (this defines what
company the rule is for). The inheritance structure is
implemented using horizontal inheritance (separate table for each
concrete sub-entity).
I would like to perform this query:
eos = EOUtilities.objectsWithQualifierFormat(ec,
"MemberRuleField", "memberRule.memberCompanyRole = %@", new NSArray
(new Object[] {memberCompanyRole}));
What I think this should do is create a query for every concrete
sub-entity. Instead, I get this:
SELECT t0.field_values, t0.long_field_values, t0.member_rule_oid,
t0.oid, t0.op, t0.rule_field_oid, t0.trans_id FROM
member_rule_field t0, null T1 WHERE T1.member_company_role_oid = ?
AND t0.member_rule_oid = T1.oid" withBindings: 1:11
(memberCompanyRoleOid)>
I only get one query, and the table name is NULL for the related
table. That unfortunately makes sense, because the memberRule
relationship points to the MemberRule entity, which is abstract
and does not have a table (yes I know, single table inheritance
would solve this problem...and vertical would probably solve it too).
Any thoughts? I would really prefer to use horizontal here...
Ken
_______________________________________________
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