Datastore String length limit of 1,500 bytes when using JDO

520 views
Skip to first unread message

Jim

unread,
Mar 2, 2017, 1:26:02 PM3/2/17
to Google App Engine
When I attempt to write a Datastore string longer than 1,500 bytes via JDO I get the following error:   "String properties must be 1500 bytes or less.  Instead, use com.google.appengine.api.datastore.Text, which can store strings of any length."

I've annotated my class to turn indexing off on this field, and I can manually insert strings (much) longer than 1,500 bytes manually via the Datastore Console.  

Is there any way to store larger String values via JDO?  It seems like an arbitrary limitation given the fact that I can manually insert larger values into the Datastore, and Datastore doc says Strings can be up to ~1MB in size.  I know I can convert these to Text but I'd rather not do that if I can avoid it.

Nick (Cloud Platform Support)

unread,
Mar 2, 2017, 6:57:41 PM3/2/17
to Google App Engine
Hey Jim,

Do I understand correctly that you only see the issue when you attempt to index the field - or what's the same thing - it doesn't occur when you turn the field's indexing off? 

Cheers,

Nick
Cloud Platform Community Support

Jim

unread,
Mar 3, 2017, 1:15:26 PM3/3/17
to Google App Engine
Nick,

When I'm using the Datastore Console to manually update the table it will throw an error related to the index if I have the indexing turned on for the field and try to store a large value.  When I turn indexing off I am able to store large strings through the console.

In my Java/JDO code I am unable to store large values under either indexing condition.  I have my class annotated to turn indexing off like this:

    @Persistent
    @Extension(vendorName="datanucleus", key="gae.unindexed", value="true")
    private String meterOptions;

Jim

Adam (Cloud Platform Support)

unread,
Mar 5, 2017, 6:18:40 PM3/5/17
to Google App Engine
There's no special JDO extension for Datastore that will automatically treat a String as Text, unfortunately. Even if there was, setting 'unindexed' for a String property wouldn't be a big enough hint to treat it as Text, because there's still a difference in Datastore between an unindexed String property and a Text property. If you want to persist a Text property in JDO, the way to do it is:

@Persistent
private Text meterOptions;
Reply all
Reply to author
Forward
0 new messages