3
votes

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?

3

3 Answers

3
votes

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

0
votes

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
0
votes

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.