title: How to Continue bulk inserts when exception occurs
body: <p>I am using jpa with hibernate I want to insert 100 record in Database, suppose I get  exception   JDBC batch update in 50th record insertion i need to handling the Exception and I need to persist remaining record to DB.</p>
  
  <p>Code:</p>
  
  <pre><code> private List&lt;TempCustomers&gt; tempCustomer =new ArrayList&lt;TempCustomers&gt;();
  
      public String migrateCustomers() {
  
        TempCustomers temp = null;
          for(DoTempCustomers tempCustomers:doTempCustomers){
  
                try {
                  temp=new TempCustomers();
                  BeanUtils.copyProperties(temp, tempCustomers);
                          tempCustomer.add(temp);
                      entityManager.persist(temp);
  
  
                }catch (Exception e) {
                    tempCustomer.add(temp);
                    entityManager.persist(temp);
                    log.info("Exception ..."+e);
                    return "null";
                }
          }
  
  
          return "null";
      }
  </code></pre>