title: Java Spring Jpa saveAll method fails if one object hits a unique constaint
body: <p>I am currently working in a spring boot project where i need to save new objects in the database.
  I have created an ArrayList where I add all these objects to be stored.</p>
  
  <p><code>List&lt;Visit&gt; visitsToBeStored = new ArrayList&lt;&gt;();</code></p>
  
  <p><code>visitsToBeStored.add(visitService.constructVisit(customer));</code></p>
  
  <pre><code>//VisitService method
  public Visit constructVisit(Customer customer){
          Visit visit = new Visit();
          visit.setCustomer(customer);
          return visit;
      } 
  </code></pre>
  
  <pre><code>visitRepository.saveAll(visitsToBeStored);
  </code></pre>
  
  <pre><code>//Visit entity
  @Entity
  @Getter
  @Setter
  @Table(name="visits" , indexes = {@Index(name="customer_createdDate_index", columnList="Customer_Id,created_at", unique=true)})
  @NoArgsConstructor
  @EntityListeners(AuditingEntityListener.class)
  public class Visit {
      @Id
      @GeneratedValue(strategy= GenerationType.IDENTITY)
      @Column(unique=true, nullable=false, precision=10)
      private int id;
      @OneToOne
      @JoinColumn(name="Customer_Id", nullable = false)
      private Customer customer;
      @CreatedDate
      @Column(name="created_at", nullable = false)
      private Date createdAt;
  }
  </code></pre>
  
  <pre><code>//Customer entity
  @Entity(name="customers")
  @Table(name="Customers")
  @Getter
  @Setter
  @NoArgsConstructor
  public class Customer implements Serializable {
  
      @Id
      @GeneratedValue(strategy=GenerationType.IDENTITY)
      @Column(name="Customer_Id", unique=true, nullable=false, precision=10)
      private int customerId;
      @Column(name="Mobile_Number", precision=20)
      private Long mobileNumber;
      @Column(name="Send_Date")
      private Timestamp sendDate;
      @Column(name="Valid", precision=3, columnDefinition = "TINYINT(3)")
      private Short valid;
      @Column(name="Pending", precision=3, columnDefinition = "TINYINT(4)")
      private Short pending;
      @Column(name="u_number", precision=20)
      private Long unumber;
      @Column(name="Email", length=45)
      private String email;
  
  
  }
  
  
  </code></pre>
  
  <p>The Visit class has unique constaint for customer.
  My problem occurs when the list has an object with a customer that is already persisted in the database.
  In that case the whole query fails.
  I would like to save all other visitsToBeStored objects except these that have failed because of the existence of constaint.
  Is there a way to do this with a jpa save method ? 
  I prefer not checking the existence of the object before addition in the list. This is my worst solution in this.</p>
  
  <p>Thanks in advance</p>