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

时间:2018-10-04 10:42:21

标签: java spring-data spring-data-mongodb mongodb-java

我有一个简单的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;
    }

}

这是我的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);

}

但是,在尝试删除时,出现错误消息-未找到类型为com.apeiron.dataModel.plan.PlanRecoveryStrategy类型的对象的id属性

错误原因是什么?

1 个答案:

答案 0 :(得分:0)

只需创建带有@Id批注的字段并为其创建吸气剂和吸气剂