How to retrieve Text type from Datastore Google Cl

2019-07-20 04:39发布

Ok, These are all basic questions but there are not many answers found on the Internet.

OK, Now, I insert into Datastore using this Java code

Text descriptionText=new Text(description);
structureEntity.setUnindexedProperty("Description",descriptionText);

Anh here is the retrieving code:

Text description=(Text)structureObjectEntity.getProperty("Description");\
System.out.println(description);

Now, let say, I insert "We should arrive before dark.<br>I should have finished the book by Friday. <br>The roads should be less crowded today.<br><br>Source: http://www.oxfordlearnersdictionaries.com/definition/english/should?q=should" into Datastore

But when retrieving data, the System.out.println(description); return <Text: We should arrive before dark.<br>I should have finished the book by Fr...> (some data got lost & there is <Text: at the head of the data & ... at the tail of the data) & that messed up everything.

So, How to retrieve Text type from Datastore Google Cloud?

1条回答
够拽才男人
2楼-- · 2019-07-20 05:18

You need to call the getValue() method. If you pass the Text object to println() it will call the toString() method. Here are the Javadocs

查看更多
登录 后发表回答