'only created primary key and other attributes null in spring boot jpa

I am try to insert(@post) using postman and and when quest I get my attributes and the status code is 200 . it means my My work properly and I guess the problems is input value (json).The tables are auto create when i run spring boot project .

here is input

{
"orders" : {
    "date":"as",
    "customer":"2",
    "orderdetails" : [
                        {   
                          "quantity":2,  
                          "items":3
                        }
                     ]
           }
}

enter image description here

ordermodel

@Entity
public class orders {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private  Long orderId;
    private  String date;

    @ManyToOne
    @JoinColumn(name = "customer_id", foreignKey = @ForeignKey(name = "customer_ID_FK"))
    private  Customer customer;

    @OneToMany(targetEntity = orderdetails.class, cascade = CascadeType.ALL)
    @JoinColumn(name ="order_fk", referencedColumnName = "orderId")
    private  List<orderdetails> orderdetails ;

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    public List<de.noellang.customerapi.entity.orderdetails> getOrderdetails() {
        return orderdetails;
    }

    public void setOrderdetails(List<de.noellang.customerapi.entity.orderdetails> orderdetails) {
        this.orderdetails = orderdetails;
    }
}

orderdetails model

@Entity
public class orderdetails {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private  Long Odid;
    private  int quantity;
/*    @OneToOne
    @JoinColumn(name ="orderidd_fk" , foreignKey = @ForeignKey(name ="orderid"))
    orders orders;*/

     @ManyToOne
    @JoinColumn(name ="itemid_fk", foreignKey = @ForeignKey(name ="item_fk"))
     private  Items items;





    public Long getOdid() {
        return Odid;
    }

    public void setOdid(Long odid) {
        Odid = odid;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public Items getItems() {
        return items;
    }

    public void setItems(Items items) {
        this.items = items;
    }


}

repository

@Service
public interface orderRepository extends JpaRepository<orders,Long> {

}
@Service
public interface orderDetailsRepository extends JpaRepository<orderdetails,Long> {
}

and controller

@RestController
@RequestMapping("/order")
public class orderController {
    @Autowired
    private orderRepository orderRepository;

    private orderDetailsRepository  orderDetailsRepository;


    @PostMapping("/insert")
    private orders makeOrder(@RequestBody orders orders){
        return orderRepository.save(orders);
    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source