App Engine - Objectify - Storing a byte[]
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
?
Why don't you retrieve as Blob
(or ShortBlob
) and then take the byte[]
out of that with getBytes()
?
I would try with:
- Using ShortBlog in your Pojo User class
- Converting Byte[] to String using String instead of Byte to store your password
- Posting a request to Objectify google group
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.
精彩评论