Не удалось прочитать зафиксированные данные в TransactionalEventListener.JAVA

Программисты JAVA общаются здесь
Ответить
Гость
 Не удалось прочитать зафиксированные данные в TransactionalEventListener.

Сообщение Гость »


I'm trying to read my previously committed data in

Код: Выделить всё

@TransactionEvenListener
annotated method which has default transaction phase but can't. Actually data is committing pretty fine, I can see it after transaction end, in DB or even if I do not use

Код: Выделить всё

REQUIRES_NEW
as propagation, I still can read in programmatically. The only thing I suspect is ChainedTransactionManager I used, which I do not know why but I can't see any other issues can cause this.

Код: Выделить всё

@Component
class MyTransactionalDomainEventHandler {

private final MyRepository myRepository;

@TransactionalEventListener
@Transactional(transactionManager = "myChainedTransactionManager", propagation = Propagation.REQUIRES_NEW)
public void onMyDomainEvent(MyDomainEvent event) {
MyEntity myEntity = myRepository.findById(event.getEntityId()); //entity is inserted in transaction that cause to work this listener.
}
}
But if I use

Код: Выделить всё

REQUIRED
as propagation then I can fetch my entity.

Код: Выделить всё

TransactionalEventListener
default has

Код: Выделить всё

AFTER_COMMIT
transaction phase, I expected it to commit before listener works. If it is committed then it shouldn't be issue to read it in other transaction, regardless of isolation level. Where am I doing wrong?


Источник: https://stackoverflow.com/questions/781 ... ntlistener
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»