私はMongoDbとMorphiaにまったく慣れておらず
、ドキュメントを更新する方法を学ぼうとしています。
このページからそれを行う方法を見る/理解することはできません:
http ://www.mongodb.org
私のドキュメントは次のようになります:(ここでエラーが発生する可能性があります)
@Entity
public class UserData {
private Date creationDate;
private Date lastUpdateDate;
@Id private ObjectId id;
public String status= "";
public String uUid= "";
public UserData() {
super();
this.statistic = new Statistic();
this.friendList = new FriendList();
}
@Embedded
private Statistic statistic;
@Embedded
private FriendList friendList;
@PrePersist
public void prePersist() {
this.creationDate = (creationDate == null) ? new Date() : creationDate;
this.lastUpdateDate = (lastUpdateDate == null) ? creationDate : new Date();
}
}
UserData
そのページでは、特定のLikeifを持っているuUid
私の更新方法を説明している場所を見ることができませupdate UserData.status
んuUid=123567
これは私が使うべきだと思うものです:
ops=datastore.createUpdateOperations(UserData.class).update("uUid").if uuid=foo..something more here..
// morphiaのデフォルトの更新では、すべてのUserDataドキュメントが更新されるため、選択したドキュメントを更新する方法
datastore.update(datastore.createQuery(UserData.class), ops);