I did some badness today.
I wanted an integration test to check to see if my @Transactional method actually did rollback on an optimistic lock failure. It’s a pretty business critical method so I wanted to be sure that the whole @Transactional and @Version annotation voodoo actually works.
The approach I took was to inject, what I called a “slowRepository” into the object with the @Transactional method. The slowRepository is just a mockito mock of the object which “answers” (using “thenAnswer”) to the “findBy…” with some custom code.
The idea is that at some point during the @Transactional method the slowRepository is called and the “answer” code is invoked. In the test, the answer code follows along the lines of:
1. Grab the data it requires from the (not slow) repository (the repository the slowRepository is mocking)
2. Switch back the slowRepository for the not slow repository
3. Invoke the @Transactional method again on a separate thread
4. Sleep for a bit
5. Wake up and return the data from step 1
The @Transactional call on the separate thread completes and commits before slowRepository wakes up. When it does, slowRepository returns stale data and the @Transactional method then fails accordingly.
The problem I encountered was using the setters for my @Autowired dependencies on the bean with the @Transactional method. I needed to use the setters so that I could switch in and out the slowRepository, but couldn’t because Spring AOP proxies are implementations of an interface, not subclasses (by default – yes I realise you can get Spring to proxy the target class using CGLIB). I found this blog post which explains how to get at the target object behind a Spring proxy. I converted it to Scala:
…which is pretty ninja.
http://ctphome.com/bbs/home.php?mod=space&uid=17012
http://dancecharts.at/forum/member.php?u=76205
отзывы о препаратах повышающих потенцию
http://ctphome.com/bbs/home.php?mod=space&uid=15235
http://bbs.manbuwl.com/home.php?mod=space&uid=141799
https://site656832719.fo.team
виагра аптека
http://bbs.manbuwl.com/home.php?mod=space&uid=150425
https://2j0rfo.zombeek.cz
http://endurancemag.free.fr/forum/profile.php?mode=viewprofile&u=28594
http://bbs.manbuwl.com/home.php?mod=space&uid=142460
https://telegra.ph/Rogatka-dlya-ohoty-01-04
http://empyrethegame.com/forum/memberlist.php?mode=viewprofile&u=213856
https://site795457697.fo.team
https://site996281100.fo.team
http://empyrethegame.com/forum/memberlist.php?mode=viewprofile&u=228222
http://forum.priboridetali.ru/member.php?u=394903
фриспины за регистрацию 2026 Бездепозитные фриспины при всей их привлекательности имеют и определенные недостатки. Главный из них — строгие и зачастую трудновыполнимые условия отыгрыша особенно для новичка. Кроме того многие казино ограничивают количество игровых автоматов на которых можно использовать бесплатные вращения что сужает выбор. Существует также риск что увлекшись возможностью легкого старта игрок может необдуманно перейти к игре на реальные деньги не будучи психологически готовым к ответственности. Поэтому подобные бонусы стоит рассматривать в первую очередь как демо-версию или ознакомительную возможность а не как надежный способ заработка.
http://forum.priboridetali.ru/member.php?u=388291
https://www.bitsdujour.com/profiles/ihERLN
http://forum.ll2.ru/member.php?641510-MichaelVoisy
https://www.bitsdujour.com/profiles/b7T8m4
https://telegra.ph/Vred-kureniya-na-organizm-cheloveka-12-25
http://bbs.manbuwl.com/home.php?mod=space&uid=162755
https://telegra.ph/Plohaya-ehrekciya-s-lyubovnicej-02-13
http://forum.priboridetali.ru/member.php?u=401849
купить набор для влюбленных Иваново
https://sjmuvx.zombeek.cz
купить попперс Ставрополь
фриспины за регистрацию без депозита 2026 В мире онлайн-казино где каждый игрок ищет свой счастливый билет одним из самых привлекательных предложений являются фриспины за регистрацию. Это не просто бонус это приглашение в игру без первоначальных вложений шанс испытать удачу и возможно даже выиграть реальные деньги не рискуя своими собственными. Давайте разберемся что это такое как их получить и на что обратить внимание.
амстердам зеро попперс отзывы
фриспины за регистрацию без депозита 2026 Фриспины за регистрацию – это безусловно одно из самых привлекательных предложений в мире онлайн-казино. Они предоставляют уникальную возможность начать игру без риска познакомиться с новыми слотами и возможно даже пополнить свой кошелек. Однако как и любой бонус они требуют внимательного изучения условий и правил. Всегда читайте мелкий шрифт чтобы избежать разочарований и максимально использовать свой шанс на удачу Удачи в игре
https://qohnrh.zombeek.cz
https://snippet.host/rcwxyb
купить попперс Саратов
https://telegra.ph/Skazki-v-pereskaze-tolstogo-lva-nikolaevicha-01-04
https://site302951571.fo.team
https://w0czkh.zombeek.cz
https://site754945957.fo.team
https://gk81n9.zombeek.cz
https://telegra.ph/Rush-poppers-10-ml-12-30
https://dinhp8.zombeek.cz
сиалис или импаза что лучше
https://telegra.ph/Vek-adalin-smotret-01-24
https://site788206254.fo.team
https://telegra.ph/Kak-raz-pod-rozhdestvo-11-22
https://teletype.link/stoodiwj411
https://telegra.ph/Kredit-vebmani-11-08-27
https://telegra.ph/Trimming-sobak-11-18
https://telegra.ph/Detskaya-poliklinika-10-dzerzhinsk-udrisa-raspisanie-vrachej-pediatrov-12-01