java - @Transactional multiple update; commit every single query -


i have 2 methods in service

public void updateall() {    long[] ids = new long[] {1,2,3,4,5,6,7,8,9,10};    (long id : ids) {         updateid(id);     } }  public updateid(long id) {   repository.update(id); } 

let's assume after 5th update have exception, first 4 operations committed anyway.

i'm using @transactional annotation if put annotation in both methods doesn't work.

do need other parameter?? might propagation??

could show me how set methods?

thank you!!

just have:

@transactional(propagation = propagation.requires_new) public updateid(long id) { } 

but, important bit, call method class. i.e. move loop out of class.

the transactional annotations kick-in when public method called outside. within same class, calling 1 transactional method still use transaction of first method.


Comments

Popular posts from this blog

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

javascript - Confirm a form & display message if form is valid with JQuery -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -