尝试使用 GAE 中的端点检索列表时,我似乎遇到了错误。错误如下:
04-08 01:01:30.145: I/System.out(14650): com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
04-08 01:01:30.145: I/System.out(14650): {
04-08 01:01:30.145: I/System.out(14650): "code": 400,
04-08 01:01:30.145: I/System.out(14650): "errors": [
04-08 01:01:30.145: I/System.out(14650): {
04-08 01:01:30.145: I/System.out(14650): "domain": "global",
04-08 01:01:30.145: I/System.out(14650): "message": "java.lang.IllegalArgumentException: id cannot be zero",
04-08 01:01:30.145: I/System.out(14650): "reason": "badRequest"
04-08 01:01:30.145: I/System.out(14650): }
04-08 01:01:30.145: I/System.out(14650): ],
04-08 01:01:30.145: I/System.out(14650): "message": "java.lang.IllegalArgumentException: id cannot be zero"
04-08 01:01:30.145: I/System.out(14650): }
这是我试图在我的端点中使用的方法:
@SuppressWarnings({ "cast", "unchecked"})
public List<Comercio> listComercio() {
EntityManager mgr = getEntityManager();
List<Comercio> result= new ArrayList<Comercio>();
try {
Query query = mgr.createQuery("select c from Comercio c", Comercio.class);
for (Object obj : (List<Object>) query.getResultList()) {
result.add((Comercio) obj);
}
} finally {
mgr.close();
}
return result;
}
}
这是实体类:
@Entity
public class Comercio{
@Id
private Long id;
private String title;
private String url;
private String NEWSTYPE;
public Comercio() {
}
public Long getId() {
return id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public void setNewstypeid(String newstypeid) {
this.NEWSTYPE = newstypeid;
}
public String getNewstypeid() {
return NEWSTYPE;
}
}
这是我的 android 项目中的 AsyncTask:
public class AsyncDatastoreArticles extends CloudAsyncTask {
AsyncDatastoreArticles(Home activity) {
super(activity);
}
@Override
protected void doInBackground() throws IOException {
// TODO Auto-generated method stub
List<Comercio> list = endpoint.listComercio().execute().getItems();
if (list != null) {
//DO SOMETHING
}
}
}
请我需要帮助。
提前致谢。