App Engine - Objectify - 存储字节[]

发布于 2024-08-28 01:51:02 字数 396 浏览 4 评论 0原文

我正在使用 Objectify 库与应用程序引擎数据存储区进行交互。

在我的 User 类中,我将哈希密码存储为 byte[]。当我将其放入数据存储区时,它被正确存储为 blob

当我尝试重新加载 User 对象时,出现以下错误:

java.lang.IllegalStateException: Cannot load non-collection value ''进入 private byte[]

我该如何解决这个问题?

我是否必须更改我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

桃酥萝莉 2024-09-04 01:51:02

为什么不检索为 Blob (或 ShortBlob),然后使用 getBytes() 从中取出 byte[]

Why don't you retrieve as Blob (or ShortBlob) and then take the byte[] out of that with getBytes()?

还给你自由 2024-09-04 01:51:02

我会尝试:

  1. 在 Pojo User 类中使用 ShortBlog 使用
  2. String 而不是 Byte 将 Byte[] 转换为 String 来存储密码
  3. 将请求发布到 具体化 Google 群组

I would try with:

  1. Using ShortBlog in your Pojo User class
  2. Converting Byte[] to String using String instead of Byte to store your password
  3. Posting a request to Objectify google group
明媚殇 2024-09-04 01:51:02

我建议只使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文