Невозможно удалить данные по id из solr (используя SolrCrudRepository), другие функции работают нормально - добавление данных, getbyId, getAll - PullRequest
0 голосов
/ 23 апреля 2020

Вот контроллер и класс сущности. FindById работает нормально, но данные не удаляются. Я расширяю свой интерфейс хранилища для SolrCrudRepository. Поскольку findById работает нормально, я не думаю, что есть какая-либо проблема при извлечении данных для удаления функции solr. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


 package com.third.solrspring.controller;

    import java.util.ArrayList;
    import java.util.List;

    import javax.annotation.PostConstruct;

    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.bind.annotation.DeleteMapping;
    import org.springframework.web.bind.annotation.GetMapping;
    import org.springframework.web.bind.annotation.PathVariable;
    import org.springframework.web.bind.annotation.PostMapping;
    import org.springframework.web.bind.annotation.RequestBody;
    import org.springframework.web.bind.annotation.RestController;

    import com.third.solrspring.model.Order;
    import com.third.solrspring.repository.Repository;

    @RestController
    public class Controller {
        @Autowired
        private Repository orderRepository;



        @PostMapping("/order")
         public String createOrder(@RequestBody Order order) {
          String description = "Order Created";
          orderRepository.save(order);
          return description;
         }

         @GetMapping("/order/{orderid}")
         public Order readOrder(@PathVariable Long orderid) {
             System.out.println(orderid);
          return orderRepository.findByOrderid(orderid);
         }

         @DeleteMapping("/order/{orderid}")
         public String deleteOrder(@PathVariable Long orderid) {
          String description = "Order Deleted";
          orderRepository.delete(orderRepository.findByOrderid(orderid));
          return description;
         }

         @GetMapping("/order/getAll")
         public Iterable<Order> getOrders()
         {
             return orderRepository.findAll();
         }

    }
    ___________________________________________________________________
    Entity Class

    package com.third.solrspring.model;

    import org.apache.solr.client.solrj.beans.Field;
    import org.springframework.data.annotation.Id;
    import org.springframework.data.solr.core.mapping.SolrDocument;

    @SolrDocument(collection = "Order")
    public class Order {

        @Id
        @Field
        private long orderid;
        @Field
        private String productName;
        @Field
        private String customerName;
        public long getOrderid() {
            return orderid;
        }
        public void setOrderid(long orderid) {
            this.orderid = orderid;
        }
        public String getProductName() {
            return productName;
        }
        public void setProductName(String productName) {
            this.productName = productName;
        }
        public String getCustomerName() {
            return customerName;
        }
        public void setCustomerName(String customerName) {
            this.customerName = customerName;
        }

        @Override
        public String toString() {`enter code here`
            return "Order [orderid=" + orderid + ", productName=" + productName + ", customerName=" + customerName + "]";
        }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...