title: SpringBoot JPA Interface's save() and delete() not working with ArrayList or Long
body: <p>I am following a tutorial that uses SpringBoot 1.3. I am on the latest release of SpringBoot 2.0. I am working on creating an REST API. I need help adapting the 1.3 code to 2.0 compliance as <code>save()</code> and <code>delete()</code> now expect objects over <code>long id</code>s. <strong>How do I need to rewrite the interface to accept <code>long id' and 'ArrayList</code>?</strong></p>
  
  <p>Here's the code as it stands:</p>
  
  <h2>The Base Object</h2>
  
  <pre><code>@Entity
  public class HotelBooking {
  
  @Id
  @GeneratedValue(strategy = GenerationType.SEQUENCE)
  private long id; // could be Long
  
  private String hotelName;
  private double pricePerNight;
  private int nbOfNights;
  
  public HotelBooking(){} 
  
  public HotelBooking(String hotelName, double pricePerNight, int nbOfNights) {
      this.hotelName = hotelName;
      this.pricePerNight = pricePerNight;
      this.nbOfNights = nbOfNights;
  }
  // getters omitted
  }
  </code></pre>
  
  <h2>The Interface</h2>
  
  <pre><code>@Repository
  public interface BookingRepository extends JpaRepository&lt;HotelBooking, Long&gt; {
  data/jpa/docs/2.1.0.M1/reference/html/
      List&lt;HotelBooking&gt; findByPricePerNightLessThan(double price);
  }
  </code></pre>
  
  <h2>Using a <code>long id</code> to delete an entry in the <code>database</code></h2>
  
  <pre><code>@RequestMapping(value = "/delete/id")
  public List&lt;HotelBooking&gt; remove(@PathVariable long id) {
      bookingRepository.delete(id);
      return bookingRepository.findAll();
  }
  </code></pre>
  
  <h2>Trying to save an ArrayList object to the <code>database</code></h2>
  
  <pre><code> @Override
      public void run(String... strings) throws Exception {
  
          List&lt;HotelBooking&gt; bookings = new ArrayList&lt;&gt;();
  
          bookings.add(new HotelBooking("Marrior", 200.50, 3));
          bookings.add(new HotelBooking("Ibis", 90, 4));
          bookings.add(new HotelBooking("Novotel", 140.74, 1));
  
          bookingRepository.save(bookings);
      }
  </code></pre>
  
  <h2>The Problem</h2>
  
  <p>The above do not work in SpringBoot 2.0 anymore. <strong>When trying to delete via ID</strong> I get an error saying - <code>Error:(61, 34) java: incompatible types: long cannot be converted to romaniancoder.booking.HotelBooking</code>
  It is now expecting an object instead of a <code>long id</code> to find an object in the database. </p>
  
  <p>When <strong>trying to save an ArrayList I get this error</strong> - <code>Error:(40, 26) java: method save in interface org.springframework.data.repository.CrudRepository&lt;T,ID&gt; cannot be applied to given types;
    required: S
    found: java.util.List&lt;romaniancoder.booking.HotelBooking&gt;
    reason: inferred type does not conform to upper bound(s)
      inferred: java.util.List&lt;romaniancoder.booking.HotelBooking&gt;
      upper bound(s): romaniancoder.booking.HotelBooking</code>
  It's as if it needs a class extended or something to work? I am not sure...</p>
  
  <p>After reading the Spring Docs I don't understand why this changed and how I can write code to accept a <code>long id</code> to find something in the <code>database</code>. I don't understand how to adapt <code>save()</code> to accept <code>ArrayLists</code>. </p>