ItEr42S17CUGravacionModelosUnidadesTraballoItEr41S20: Adding runOnAnotherTransaction to execute code in another transaction
This commit is contained in:
parent
78ac3bad02
commit
dbde962415
2 changed files with 9 additions and 0 deletions
|
|
@ -21,6 +21,7 @@
|
|||
package org.navalplanner.business.common;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
|
|
@ -38,4 +39,10 @@ public class AdHocTransactionService implements IAdHocTransactionService {
|
|||
return onTransaction.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public <T> T runOnAnotherTransaction(IOnTransaction<T> onTransaction) {
|
||||
return onTransaction.execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,4 +27,6 @@ public interface IAdHocTransactionService {
|
|||
|
||||
public <T> T runOnReadOnlyTransaction(IOnTransaction<T> onTransaction);
|
||||
|
||||
public <T> T runOnAnotherTransaction(IOnTransaction<T> onTransaction);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue