views:

165

answers:

2

Google App Engine - When I want to store a byte array as one of the fields of my entity class, do I have to specify it as of type Blob or ShortBlob instead of byte[]?

+1  A: 

I'm pretty sure you have to. You can always convert to Blob/ShortBlob for storage only and convert it back into a byte[] immediately after you restore it.

Pace
And yes, that breaks the "POJO" paradigm of the AppEngine/DataStore. The main advantages of using POJO as datastore model is to reuse the same model classes in other parts of the application. Using Blob induce (another) dependency from your domain to appengine.
lOranger
+3  A: 

If you need to store a Byte array you have two choices:

  1. com.google.appengine.api.datastore.ShortBlob : short byte string, < 500 bytes
  2. com.google.appengine.api.datastore.Blob: long byte string (not orderable)
systempuntoout