On Tue, Nov 15, 2011 at 10:30 PM, Gerald Tan <woefulwab...@gmail.com> wrote:
> Only Serializable objects can be used as properties, and Cipher isn't > serializable. The solution is to store the algorithm as a String, then > reinstantiating the Cipher from the algorithm string after retrieving it > from the datastore. This is almost right - it's not about being Serializable. GAE only lets you store certain basic types (Long, String, Text, Blob, GeoPt, and about a dozen others including collections of these types). They aren't stored with java serialization; I believe the native structure is protobuf but this is opaque outside of Google. Objectify extends this list somewhat by automatically converting some types into ones the datastore recognizes (for example, String[] into List<String>, byte[] into Blob, fields with @Serialized annotation into Blob, etc). But there are practical limits. We didn't go through every single JDK class figuring out how to store it in appengine. Cipher, IvParameterSpec, SecretKeySpec are not storeable types. Cipher doesn't even make sense to store - you probably just want to store the algorithm with which the Cipher was created. IvParameterSpec and SecretKeySpec are probably best stored as byte[] (which Ofy will convert to Blob) or, if you prefer, can be Base64 or hex encoded into a String. There are situations when you will want to build Objectify Converters so that fields can have "normal" types; for example, if you use Joda Time or Joda Money classes (Objectify includes converters for these, but they aren't enabled by default). I won't tell you that it's wrong to use IvParameterSpec and SecretKeySpec fields, but for the most part you should be cautious of using exotic types in your data model - especially when they are interfaces without a concrete type definition. I wouldn't do it. Jeff -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-java@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.