mercredi 15 avril 2015

Spring JPA deleteInBatch causes StackOverflow

I have a question to deleting Items from db using deleteInBatch. I have an object A having a list of Objects B like:



class A {
private List <B>;
}


The list contains more than 7k elements. So now I have to remove A and all its elements. I tried via deleteInBatch but I get



org.springframework.web.util.NestedServletException: Handler processing failed;
nested exception is java.lang.StackOverflowError


Deleting the items with a sipmle delete method works but it takes more than 5 minutes. My delete code is:



public void delete(Long id) {
A a = repository.findOne(id);
deleteElements(a);
repository.delete(a);
}

private void deleteElements(A a) {
repository.deleteInBatch(a.getListOfB);
}


Is there a good solution to speed up the deleting process or how to change so that deleteinbatch does not take all hibernate stack - without increasing it?


Aucun commentaire:

Enregistrer un commentaire