简体   繁体   English

Spring JPA + Mongo-无法通过查询删除

[英]Spring JPA + Mongo - Unable to delete by query

I have simple Java Class that is getting stored to MongoDB through Spring JPA - 我有一个简单的Java类,该类通过Spring JPA存储到MongoDB中-

public class PlanRecoveryStrategy {

    String planId;
    String processId;
    String strategyId;

    public String getPlanId() {
        return planId;
    }

    public void setPlanId(String planId) {
        this.planId = planId;
    }

    public String getProcessId() {
        return processId;
    }

    public void setProcessId(String processId) {
        this.processId = processId;
    }

    public String getStrategyId() {
        return strategyId;
    }

    public void setStrategyId(String strategyId) {
        this.strategyId = strategyId;
    }

}

This is my DataAccessObject Class - 这是我的DataAccessObject类-

@Repository("PlanRecoveryStrategy")
public interface PlanRecoveryStrategyDao extends MongoRepository<PlanRecoveryStrategy, String> {

    @Query(value = "{ 'planId' : ?0, 'processId' : ?1, 'strategyId' : ?2}", delete = true)
    List<PlanRecoveryStrategy> deletePlanRecoveryStrategy(String planId, String processId, String strategyId);

}

However, on trying to delete, I get the error saying - No id property found for object of type class com.apeiron.dataModel.plan.PlanRecoveryStrategy 但是,在尝试删除时,我收到以下错误消息:找不到类型为com.apeiron.dataModel.plan.PlanRecoveryStrategy类型的对象的id属性

What is the reason for the error? 错误的原因是什么?

只需创建一个带有@Id注释的字段并为其创建getter和setter方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM