App Engine - Objectify - 存储字节[]
我正在使用 Objectify 库与应用程序引擎数据存储区进行交互。
在我的 User 类中,我将哈希密码存储为 byte[]
。当我将其放入数据存储区时,它被正确存储为 blob
。
当我尝试重新加载 User
对象时,出现以下错误:
java.lang.IllegalStateException: Cannot load non-collection value '
我该如何解决这个问题?
我是否必须更改我的 User 类才能使哈希密码为 ShortBlob
类型?
I'm using the Objectify library for interfacing with the app engine datastore.
In my User class, I store the hashed password as a byte[]
. When I put it in the datastore, it is correctly stored as a blob
.
When I try to load the User
object back out I get this error:
java.lang.IllegalStateException: Cannot load non-collection value '<Blob: 40 bytes>' into private byte[]
How do I fix this?
Do I have to change my User class to have the hashed password be of type ShortBlob
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为什么不检索为
Blob
(或ShortBlob
),然后使用getBytes() 从中取出
byte[]
?Why don't you retrieve as
Blob
(orShortBlob
) and then take thebyte[]
out of that withgetBytes()
?我会尝试:
I would try with:
我建议只使用 md5 'd 字符串?
另一种可能性是,当您尝试加载字节时,Objectify 尚未正确注册用户。 “objectify”最佳实践中有一个链接
http://code.google .com/p/objectify-appengine/wiki/IntroductionToObjectify#Relationships
建议静态注册您的 PoJo 类。
I suggest just use a md5 'd string?
Another possibility is when u try to load the byte, the User hasn't been registered properly by Objectify. there's a link in the 'objectify's' best practices
http://code.google.com/p/objectify-appengine/wiki/IntroductionToObjectify#Relationships
that suggests static registration of your PoJo classes.