Google App Engine开发之Text

来源:互联网 发布:兄弟连linux 编辑:程序博客网 时间:2024/06/05 10:24

一般定义如下格式就可:

@Persistent(defaultFetchGroup = "true")
 private Text Elements;

 

public String getElements()
 {
  return this.Elements.getValue();    
 }
 public void setElements(String _value)
 {
  this.Elements = new Text(_value);
 }

 

 

常出现的问题:

org.datanucleus.exceptions.NucleusException: Datastore value is of type java.lang.String (must be Blob)

出现在

@Persistent(serialized="true", defaultFetchGroup="true")
private Text Elements; 下

java.lang.ClassCastException: java.lang.String cannot be cast to com.google.appengine.api.datastore.Text

@Persistent(defaultFetchGroup = "true")
 private Text Elements;

 

这类问题一般出现在使用Text类型时,究其原因应该是在变更字段类型时(即由String 转为 Text时)未将以前的数据清除,造成数据转换失败。

原创粉丝点击