0
我不知道如何解決一個問題。我在春天使用MongoDb應用程序。我有兩個對象任務和答案。每個答案都包含對任務的參考。問題是當我更新任務時,它不更新答案中的任務。也許我已經設置了一些錯誤,無論如何我不知道是什麼。spring mongodb - 更新參考
這裏是回答文檔
@Document
public class Answer {
@Id
private String id;
private String text;
private Date created;
private Date finished;
@Reference
private Task task;
@Reference
private User user;
//constructor, getters and setters
任務書
@Document
public class Task {
@Id
private String id;
private int percentageLimit = 75;
private int peopleLimit = 200;
private int priority = 0;
private int status = 0; //0=unfinished, 1=finished
private int visible = 1; //0=hidden, 1=visible
private Date created;
//constructor, getters and setters
在數據庫中,它看起來是這樣的:
任務:
"_id" : ObjectId("...."),
"_class" : "com.example.model.Task",
"percentageLimit" : 75,
"peopleLimit" : 200,
"priority" : 10,
"status" : 0,
"visible" : 1,
"created" : ISODate("....")
答:
"_id" : ObjectId("..."),
"_class" : "com.example.model.Answer"
....
....
"task" : {
"_id" : ObjectId{"...."}
"percentageLimit" : 75
...
"created" : ...
}
看起來好像沒有參考文獻,但正如您可以看到上面我註釋@Reference在答案文檔右上方任務。
有人知道如何解決這個問題嗎?
非常感謝
米哈爾
非常感謝 –