Silas Silas - 1 month ago 5x
Java Question

Google App Engine saving toString() value, not Text

I have a problem with the Google App Engine and datastorage.

When I try to save a newly created Text instance with the DataStore, it only saves the representation of toString() of that Text.

Text myText = new Text("This is a test");
entity.setProperty("value", myText);

This results in the value:

"value" : "< Text: This is a test >"

which is exactly the toString()-representation of my Text-object. Why is this happening, and how can I fix it?

Thanks for you help,
Jan Scheele

PS: I also tried setUnindexedProperty(...) with no effect.


When you are reading the value you have to use getValue -method in the Text -instance.

return ((Text) entity.getProperty("value")).getValue();