简体   繁体   中英

Spring JPA + Mongo - Unable to delete by query

I have simple Java Class that is getting stored to MongoDB through Spring JPA -

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 -

@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

What is the reason for the error?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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