MY list size is consist 5000 records i need to get 100 records every time from list then persist to 100 records each time up to 5000 records persist to DB how can achieve this logic?
private List<DoTempCustomers> doTempCustomers;
for(DoTempCustomers tempCustomers:doTempCustomers){
try {
temp=new TempCustomers();
BeanUtils.copyProperties(temp, doTemp);
getEntityManager().persist(temp);
}
my above code i was persist all 5000 records single for each loop.
Try splitting the list into parts, and then do operations on each of sublists. If you need how to split list, you can refer this link: How to split array list into equal parts? which gives you idea.