【发布时间】:2012-02-21 18:59:58
【问题描述】:
我还没有找到明确的答案,希望有人能帮助我。我想在 Mongo 中“引用”的对象上创建一个复合索引。我显然遇到了一个错误,我将在下面的代码 sn-ps 进行描述。
@Entity
public class Address {
public Address (String street, String City, String state, String zip) {
this.street = street;
this.city = city;
this.state = state;
this.zip = zip;
}
// Getters and Setters
@Id private ObjectId id;
private String street;
private String city;
private String state;
private String zip;
}
@Entity
@Indexes( @Index("location.city, name") )
public class Team {
public Team (String sport, String name, Address location) {
this.sport = sport;
this.name = name;
this.location = location;
}
// Getters and Setters
@Id private ObjectId id;
private String sport;
private String name;
@Reference private Address location;
@Reference private List<Player> players;
}
我得到的错误是:
线程“主”com.google.code.morphia.query.ValidationException 中的异常:在验证位置时无法在“com.company.test.Team”中找到“位置”之后的点符号。城市
所以我想我的问题是:我收到此错误是因为“地址”是“团队”中的引用还是我错过了其他内容?
感谢您的任何反馈。
【问题讨论】: