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.
https://yqccvk.zombeek.cz
https://telegra.ph/Muzhskie-strizhki-video-uroki-12-25
https://theexplorers.com/user?id=702894b4-1f83-4973-85af-e668d09bd59e
супер сиалис Грозный
https://site553137587.fo.team
https://doc.adminforge.de/s/MPSrzQpkEe
https://snippet.host/zqztko
https://oncpsw.zombeek.cz
1xbet resmi sitesi 1xbet-54.com .
https://telegra.ph/Avtospeccentr-vakansii-02-21
https://telegra.ph/Karagandinskaya-oblast-11-09
sweet bonanza самовиключення sweet-bonanza54072.help
купить попперс Балаково
https://paiza.io/projects/In9BeBFd70MpL20Ct9MbXg
https://snippet.host/qoavao
где можно купить депоксетин
сиалис рецепт
https://telegra.ph/Vdu-506-12-18
https://site162057762.fo.team
mostbet вывести сомы http://mostbet78063.help
https://paiza.io/projects/D71eC7azIJ0jIufVqsQhog
https://site561484879.fo.team
секс видео йога секс видео йога .
play slots on 1win http://www.1win5523.ru
österreich frankreich wetten
my webpage – basketball Wett tipps heute
https://wvly2a.zombeek.cz
мелбет авиатор игра мелбет авиатор игра
https://teletype.link/echoijt884
можно ли подмешать виагру в напиток
eigenes wettbüro eröffnen
Feel free to visit my web page: gratis guthaben ohne einzahlung sportwetten – Leonie -
https://0lxgwk.zombeek.cz
попперс евпатория
https://teletype.link/fordzza6124
wettbüro nürnberg
My blog post … Beste sportwetten online (gskcnc.com.vn)
1win depunere Victoriabank http://www.1win5808.help
https://paiza.io/projects/5QR1i2hcq_my2F0nlP6dBw
bild wett profi tipps Sportwetten (https://cert.learn.co.th/)
сиалис купить челябинск
https://telegra.ph/Aleksandra-melnichenko-01-06
ремонт гидроизоляции фундаментов и стен подвалов ремонт гидроизоляции фундаментов и стен подвалов .
маска для попперса
виагра аптека цена
Пробовал накрутку пару лет назад через дешёвые сервисы — толку не было, только деньги сжёг. Статья помогла понять, почему. Во-первых, сайт тогда был технически не готов (глубоко в выдаче). Во-вторых, использовал дешёвые прокси и сгенерированные отпечатки. Сейчас, почитав этот гайд, вижу системный подход: аудит сайта, правильный сбор семантики, плавный старт. Оставлю ссылку здесь, буду перечитывать перед запуском: https://partnerkin.com/tribuna/blog-vitalivivdenko/nakrutka-pf-v-yandekse-polnoe- . Много практических деталей.
п о п п е р с
лучшее средство для повышения потенции
1xbet mobi 1xbet-54.com .
попперс и спорт
купить попперс Стерлитамак
https://rentry.co/en7o252o
https://telegra.ph/Tovary-iz-kitaya-kupit-12-07