データベースに100レコードを挿入したい休止状態でjpaを使用しています。50番目のレコード挿入で例外JDBCバッチ更新を取得するとします。例外を処理する必要があり、残りのレコードをDBに永続化する必要があります。
コード:
private List<TempCustomers> tempCustomer =new ArrayList<TempCustomers>();
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";
}