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

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -