How can I implement a Save Or Update function using Spring Data Jpa?

I am using Spring Data JPA to save a record to my database. Here is the method I am using: @Override public void persistOrder(final Order order) { orderRepository.save(order); } and my repository:…