无法使用Core Data从DynamoDB获取相关项目 [英] Unable to fetch related item from DynamoDB using Core Data

查看:102
本文介绍了无法使用Core Data从DynamoDB获取相关项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个实体,两者之间存在一对一的关系。在测试中,我可以创建两个实体,并加入并保存它们。数据将按预期方式显示在DynamoDB中,并显示相应的ID以显示两者之间的相关性。

I have two entities with a one to one relationship between the two. In tests I can create the two entities, join and save them. The data appears in DynamoDB as expected with the appropriate ID's displayed to show the two are related.

然后,我尝试取回这些项目。我对其中一项进行了提取请求,该请求已返回,并且我可以成功记录该标识符。但是,如果我尝试记录我希望隐式获取的相关实体的标识符,则会出现以下异常:

I then attempt to retrieve the items back. I perform a fetch request for one of the items, which is returned and I can log it's identifier successfully. However, if I attempt to log the identifier of the related entity which I am expecting to have been fetched implicitly I get the following exception:

2013-01-17 15:00:13.936 DJ[10995:c07] DynamoDBResponse.m|-[DynamoDBResponse connectionDidFinishLoading:]|62|Response Body:
{"__type":"com.amazon.coral.validate#ValidationException","message":"1 validation error detected: Value null at 'key.hashKeyElement' failed to satisfy constraint: Member must not be null"}
2013-01-17 15:00:13.936 DJ[10995:c07] DynamoDBResponse.m|-[DynamoDBResponse connectionDidFinishLoading:]|92|Returned CRC32: 650439770, Calculated CRC32: 650439770
2013-01-17 15:00:13.937 DJ[10995:c07] AmazonRequestDelegate.m|-[AmazonRequestDelegate request:didFailWithServiceException:]|74|didFailWithServiceException
2013-01-17 15:00:13.937 DJ[10995:c07] DynamoDBWebServiceClient.m|-[DynamoDBWebServiceClient invoke:rawRequest:unmarshallerDelegate:]|131|Response Status Code : 400
2013-01-17 15:00:13.938 DJ[10995:c07] AmazonErrorHandler.m|+[AmazonErrorHandler errorFromExceptionWithThrowsExceptionOption:]|51|WARNING: An exception was thrown. Please call [AmazonErrorHandler shouldNotThrowExceptions] to change this behavior.
2013-01-17 15:00:13.939 DJ[10995:c07] *** Terminating app due to uncaught exception 'NSObjectInaccessibleException', reason: 'CoreData could not fulfill a fault for '0x7540100 <x-coredata://279744BC-1B25-4170-AF2C-83676954BC3D-10995-00005B7C38D21AFA/Venue/p(null)>''
*** First throw call stack:
(0x1655012 0x147ae7e 0xe6ed8 0xe6887 0xe64c1 0xe6336 0x10b000 0x260c 0x1edc 0x4a3817 0x4a3882 0x3f2a25 0x3f2dbf 0x3f2f55 0x3fbf67 0x3bffcc 0x3c0fab 0x3d2315 0x3d324b 0x3c4cf8 0x24a2df9 0x24a2ad0 0x15cabf5 0x15ca962 0x15fbbb6 0x15faf44 0x15fae1b 0x3c07da 0x3c265c 0x282d 0x1d15)
libc++abi.dylib: terminate called throwing an exception

我尝试设置:

[request setReturnsObjectsAsFaults:NO];

但结果没有差异。

在初始获取后,我没有对数据进行任何更新。我错过了什么吗?

I am not performing any updates on the data following the initial fetch. Am I missing something?

<<编辑1 >>

<< EDIT 1 >>

我从日志中看到,在访问相关对象时,发送到DynamoDB的基础消息具有空键,因此DynamoDB是正确的

I can see from the logging that when accessing the related object, the underlying message being sent to DynamoDB has a null key, so it is correct that DynamoDB can't fetch a result, but I don't understand why the key isnot being transmitted, as it is correctly listed in the DB.

<<无法获取结果,但是我不明白为什么密钥没有被传输,因为它已正确地列在数据库中。编辑2 >>

<< EDIT 2 >>

如果我添加一个一对多关系并将完全相同的实体添加到其中,然后首先访问一对多关系,我可以然后按预期通过一对一关系检索完全相同的对象。 。 。 有人能成功使用DynamoDB一对一关系吗?,因为这似乎是一个错误?

If I add a second relationship which is one to many and add the exact same entity into it, then access the one to many relationship first, I can then retrieve the exact same object via the one to one relationship as expected . . . has anyone got an example where they have successfully used DynamoDB for a one to one relationship as this seems like a bug?

推荐答案

似乎DynamoDB无法处理null或空字符串值(相反,您根本不应该具有属性),并且可能会打击您。

It seems DynamoDB cannot handle null or empty string values (instead, you shouldn't have an attribute at all), and that may be hitting you.

您可以在应用外进行类似的查询吗?在控制台中?

Can you do a similar query outside your app ? in the 'console' ?

这篇关于无法使用Core Data从DynamoDB获取相关项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆