小编The*_*bee的帖子

DatastoreNeedIndexException:找不到匹配的索引.使用Objectify

在将我的代码部署到云后使用google appengine时出现此错误,我使用objectify索引进行过滤.

这是我的包含索引的java类(Entity)文件

@Entity
public class Session{
   @Index private Integer year;
   @Index private Key<Institute> institute;
  //some other manipulation goes below
   }
Run Code Online (Sandbox Code Playgroud)

当我尝试使用objectify从数据存储区调用实体列表时

ofy().load().type(Session.class).filter("institute",t).order("year").list();//order by year
Run Code Online (Sandbox Code Playgroud)

它在我的控制台上抛出以下错误,下面的图像显示它,抱歉不太清楚

在此输入图像描述

java google-app-engine objectify google-cloud-datastore

2
推荐指数
1
解决办法
705
查看次数

在Serializable类中,Enum不在Api Explorer中设置

我有以下Enum类

public enum EventAccess {
            PUBLIC("PUBLIC"),
            EMPLOYEES_ONLY("EMPLOYEES_ONLY"),

String name;
private EventAccess(String name) {
    this.name = name;
}
public String getName() {
    return name;
   }
 }
Run Code Online (Sandbox Code Playgroud)

此外,我有一个Serializable类,其枚举作为其中一个字段

 public class EventAccessRequest implements Serializable{

private List<EventAccess> event_access = new ArrayList<>();

public EventAccessRequest() {

}

public List<EventAccess> getEvent_access() {
    return event_access;
}

public void setEvent_access(List<EventAccess> event_access) {
    this.event_access = event_access;
  }
}
Run Code Online (Sandbox Code Playgroud)

我有一个@Api方法,它创建了一个EventAccessRequest类型的对象.我在Api Explorer中设置了此请求的值,但它没有设置我放入的任何枚举字段.

@ApiMethod(name = "fetchEventByEventAccess", path = "user/events/list-by-access/", httpMethod = HttpMethod.GET)
    public RestfulResponse fetchEventByEventAccess(EventAccessRequest request)throws Exception
    {

            EventAccess x = request.getEvent_access().get(0);

            return …
Run Code Online (Sandbox Code Playgroud)

java google-app-engine enums serialization google-cloud-platform

2
推荐指数
1
解决办法
39
查看次数