考虑以下entitis(EventReactions,EventLog):
public class EventReaction extends Entity {
@Id
private String id;
private EventLog eventLog;
....
//getters and setters
}
和
public class EventLog extends Entity {
@Id
private String id;
....
//getters and setters
}
我期待以下界面
public interface EventReactionRepository extends MongoRepository<T , String>{
Optional<EventReaction> findByEventLog_Id(String id)
}
返回其eventLog id为id
的eventReactions。但是,它已经存在于mogoDB中我的查询什么也没有返回!我的查询是否正确?
答案 0 :(得分:0)
将您的代码更改为
Optional<EventReaction>
从
获取Optional<EventReaction> result= eventReactionRepository.findByEventLogId(new ObjectId("document-storage-id"));
Content-Type: application/json