@Persistent(serialized = "true") vs @Persistent

192 views
Skip to first unread message

applehund

unread,
Aug 12, 2012, 4:59:23 PM8/12/12
to google-a...@googlegroups.com
Hi there, can anyone explain the pros & cons of these two styles? Like if I have an Integer member variable:

@Persistent
private Integer foo;

@Persistent(serialized = "true")
private Integer foo;

I do know that with the serialized version I have to always mark it dirty with JDOHelper.makeDirty(...).

Is there a speed performance boost for serialized? A storage size decrease? Why wouldn't I just use @Persistent always?

Thanks everyone!

applehund

unread,
Aug 14, 2012, 7:15:40 PM8/14/12
to google-a...@googlegroups.com
*bump bump*

Amy Unruh

unread,
Aug 15, 2012, 3:55:58 AM8/15/12
to google-a...@googlegroups.com
hi,

The app engine JDO documentation goes into this in more detail-- take a look at the discussion of the field types.

A serialized field is stored as a blob property.  You can use it to set a field of your instance to some (serializable) object, with the serialization and deserialization handled for you. Blob values are not indexed and cannot be used in query filters or sort orders. 
You might want to use a serialized field if you have an object that should be part of an entity, and is not a 'core type' (or supported collection), and whose contents don't need to be indexed-- in that case it's often simplest to just serialize it wholesale.

If your field is a core type (like Integer), you don't need to serialize it -- just annotate it as 'unindexed' if you don't want it indexed.  

*bump bump*
--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/EJuts8ODccwJ.

To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.

applehund

unread,
Aug 27, 2012, 1:28:10 AM8/27/12
to google-a...@googlegroups.com, amyu+...@google.com
Thanks Amy! This makes sense :)

Another question I have is do list objects that are serialized still count towards the 5000 member field limit? So currently if I have a GAE object with:

@Persistent
private List<Object>foo;

and foo contains 5000+ objects then I can't load it from the datastore. Does this change if foo is stored as a serialized blob property instead?

@Persistent(serialized = "true")
private List<Object>foo;

Since it's not indexed?

Thanks!
Reply all
Reply to author
Forward
0 new messages