作为对象映射已解决问题的以下问题,我已将 RestKit 升级到 0.10.1 并将数据模型扩展到以下内容。
一个公司可以有多个联系人和活动,一个联系人可以有多个活动但只有一个公司,一个活动只能有一个公司和一个联系人。
有关系的实体
Company
- unitID
- companyID
- matchcode
- contacts* (Company -->> Contact | 1:n)
- activities* (Company -->> Activity | 1:n)
Contact
- unitID
- companyID
- contactID
- lastName
- firstName
- company* (Contact >--> Company | 1:1)
- activities* (Contact -->> Activity | 1:n)
Activity
- unitID
- activityID
- companyID
- contactID
- subject
- account* (Activity >--> Company | 1:1)
- contact* (Activity >--> Contact | 1:1)
JSON(公司)
[
{
"unitID":"003CABD8DEB5DC13C",
"companyID":"BSP-002999",
"matchcode":"Testcompany"
}
]
JSON(联系方式)
[
{
"unitID":"DAC2ACCC125795D00",
"companyID":"BSP-002999",
"contactID":"CLP-015468",
"firstName":"Mister",
"lastName":"Wayne"
}
]
JSON(活动)
[
{
"unitID":"E123FlADAS2DASD2F",
"activityID":"ACT-123912",
"companyID":"BSP-002999",
"contactID":"CLP-015468",
"subject":"Testsubject",
}
]
对象映射 - 设置连接
// Objects
companyMapping.primaryKeyAttribute = @"companyID";
...
contactMapping.primaryKeyAttribute = @"contactID";
...
activityMapping.primaryKeyAttribute = @"activityID";
// Connections
[contactMapping mapRelationship:@"company" withMapping:companyMapping];
[contactMapping connectRelationship:@"company" withObjectForPrimaryKeyAttribute:@"companyID"];
[activityMapping mapRelationship:@"company" withMapping:companyMapping];
[activityMapping connectRelationship:@"company" withObjectForPrimaryKeyAttribute:@"companyID"];
[activityMapping mapRelationship:@"contact" withMapping:contactMapping];
[activityMapping connectRelationship:@"contact" withObjectForPrimaryKeyAttribute:@"contactID"];
问题
前两个映射操作正常工作,但不知何故最后一个映射活动 >--> 联系人不起作用。
感谢您提供解决问题的任何想法!