21 Aralık 2017 Perşembe

TransactionSynchronizationManager Sınıfı

Giriş
Şu satırı dahil ederiz
import org.springframework.transaction.support.TransactionSynchronizationManager;
Açıklaması şöyle.
Central helper that manages resources and transaction synchronizations per thread. To be used by resource management code but not by typical application code.
isCurrentTransactionReadOnly metodu
Şöyle yaparız
@Transactional
void foo(){
  log.info("Is readonly -  " + TransactionSynchronizationManager
  .isCurrentTransactionReadOnly());
  ..
}
getCurrentTransactionName metodu
Şöyle yaparız
@Transactional
void foo(){
  log.info("Current Transaction Name -  " + TransactionSynchronizationManager
  .getCurrentTransactionName());
  ..
}
registerSynchronization metodu
registerSynchronization metodu yazısına taşıdım

setCurrentTransactionName metodu
Şöyle yaparız
@Transactional
void foo(){
  TransactionSynchronizationManager.setCurrentTransactionName("TestTransaction");
  ...
}

Hiç yorum yok:

Yorum Gönder