[baseten-users] to-many relationship defined but not seen, bug?
Jianhua Meng
jh_meng at mac.com
Sat Apr 11 22:52:29 EEST 2009
Hi List,
I don't know if this is a bug in the baseten framework or a bug on my
part. For some reason I could not figure out, a to-many relationship
in our app does not appear to be available when it is clearly defined
in the model along with many other similar relationships.
We have, in the model of interest, InsuranceCompany --(x)-->>
InsurancePlan --(y)-->> InsurancePolicy, where x and y are both to-
many relationships. x works fine and y does not. When y is accessed,
it triggers the following error:
BXDatabaseObject.m:540 -[BXDatabaseObject primitiveValueForKey:]
[0x40d640m] ERROR: Key insurancePolicies wasn't found in entity <pgsql://Wuxing.local.:5432/quickceph InsurancePlan (0x159663a0) validated: 1 enabled: 1
>. (Called from an instance of QCXInsurancePlan.)
2009-04-11 11:28:43.996 QuickCephOffice[23939:813] [<QCXInsurancePlan
0x159d25f0> valueForUndefinedKey:]: this class is not key value coding-
compliant for the key insurancePolicies.
Here's the section of the model that shows how the relationship
(insurancePolicies) is setup. Does anyone see anything wrong?
Any insights you have on the likely cause of this problem will be
greatly appreciated.
Here's the custom code we have the complaining class, QCXInsurancePlan
#import "QCXManagedObject.h"
@class QCXInsuranceCompany;
@class QCXInsurancePolicy;
@interface QCXInsurancePlan : QCXManagedObject
{
}
// attributes omitted to simplify the illustration
...
// relationships
@property (retain) QCXInsuranceCompany * insuranceCompany;
@property (retain) NSSet* insurancePolicies;
@end
@interface QCXInsurancePlan (RelationshipManagement)
- (void)addInsurancePoliciesObject:(QCXInsurancePolicy *)value;
- (void)removeInsurancePoliciesObject:(QCXInsurancePolicy *)value;
@end
From our point of view, the QCXInsurancePlan.insurancePolicies
appears to be defined properly in the model and in our code. What then
can explain for the error message? How should I go about debugging
this? I poked around the entity descriptions of QCXInsurancePlan, and
could not figure out how to interpret the results. I expected to see
all the relationships to be described there or somewhere, but I could
not find explicit evidence.
How does an entity report a to-many relationship? How do I know if a
to-many relationship is defined according to the underlying
BXEntityDescription? I don't see an explicit entry for
'insurancePolicies' in the reported results. But on the other hand, I
don't see the expected 'insurancePlans' in InsuranceCompany's
relationshipsByName report either. The latter is known to work as
expected.
(gdb) po [entity relationshipsByName] // where entity is extracted
from an instance of QCXInsurancePlan
{
InsuranceCompany = <BXRelationshipDescription (0x165684d0) name:
InsuranceCompany entity: InsurancePlan destinationEntity:
InsuranceCompany>;
InsurancePolicy = <BXRelationshipDescription (0x16568350) name:
InsurancePolicy entity: InsurancePlan destinationEntity:
InsurancePolicy>;
"PracticeManagement_InsurancePolicy_insurancePlan" =
<BXRelationshipDescription (0x16568010) name:
PracticeManagement_InsurancePolicy_insurancePlan entity: InsurancePlan
destinationEntity: InsurancePolicy>;
insuranceCompany = <BXRelationshipDescription (0x16568400) name:
insuranceCompany entity: InsurancePlan destinationEntity:
InsuranceCompany>;
}
For comparison, InsuranceCompany contains a similar to-many
relationship. Since QCXInsuranceCompany.insurancePlans works as
expected, how come I don't see insurancePlans reported here explicitly
either?
(gdb) po [[company entity] relationshipsByName] // where company is an
instance of QCXInsuranceCompany
{
AdjustedFee = <BXRelationshipDescription (0x1658b0f0) name:
AdjustedFee entity: InsuranceCompany destinationEntity: AdjustedFee>;
InsurancePlan = <BXRelationshipDescription (0x1658af30) name:
InsurancePlan entity: InsuranceCompany destinationEntity:
InsurancePlan>;
"PracticeManagement_AdjustedFee_insuranceCompany" =
<BXRelationshipDescription (0x1658b020) name:
PracticeManagement_AdjustedFee_insuranceCompany entity:
InsuranceCompany destinationEntity: AdjustedFee>;
"PracticeManagement_InsurancePlan_insuranceCompany" =
<BXRelationshipDescription (0x1658ae80) name:
PracticeManagement_InsurancePlan_insuranceCompany entity:
InsuranceCompany destinationEntity: InsurancePlan>;
}
I don't get the whole picture. Thanks for any help.
Jianhua Meng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basetenframework.org/pipermail/baseten-users/attachments/20090411/b2331071/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: model.png
Type: image/png
Size: 254112 bytes
Desc: not available
URL: <http://lists.basetenframework.org/pipermail/baseten-users/attachments/20090411/b2331071/attachment-0001.png>
More information about the baseten-users
mailing list