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://hpjtzq.zombeek.cz
https://curitum.ru/gde-iskat-vdoxnovenie-dlya-romanticheskogo-svidaniya-esli-fantaziya-issyakla/
мелбет казино скачать на айфон мелбет казино скачать на айфон .
https://orto-orel.ru/jelektronika/uchjonye-sluchajno-otkryli-jeffekt-samozazhivlenija-treshhin-v-metalle/
купить дапоксетин Раменское
https://pozhelaniye.ru/poppers-sex-bolt-energiya-svoboda-i-novye-grani-oshhushhenij/
http://www.fhnn-nn.ru/novosti/poppers-amsterdam.html
https://mirror-venus.ru/raznoe/poppersy-osobennosti-preimushhestva-i-vliyanie-na-vospriyatie
https://fakepatekphilippe.ru/romanticheskoe-svidanie-kak-sozdat-atmosferu-doveriya-i-blizosti
sportwetten lizenz kaufen
my web page … wettbüro osnabrück – Callie -
https://gost-snip.su/dbysgvd
https://snippet.host/dmuemx
https://newsos.ru/10012-vse-chto-nuzhno-znat-o-poppersah-rukovodstvo-dlja-pokupatelej.html
https://vertinvest.ru/2023/11/29/jandeks-disk-dast-32-gigabajt-mesta-za/
https://telegra.ph/K-chemu-snitsya-pavlin-11-14
https://heygaga.ru/iskusstvo-romanticheskogo-svidaniya-kak-sozdat-magiyu-vdvoyom
https://paint-club.ru/kupit-poppers-chto-jeto-kak-vybrat-i-na-chto-obratit-vnimanie/
https://dajd.ru/kak-organizovat-nezabyvaemoe-romanticheskoe-svidanie-idei-i-vdohnovenie/
https://qr8tud.zombeek.cz
https://protrud.com/%d0%bf%d0%be%d0%bf%d0%bf%d0%b5%d1%80%d1%81-amsterdam-%d1%8d%d0%bd%d0%b5%d1%80%d0%b3%d0%b8%d1%8f-%d1%81%d0%b2%d0%be%d0%b1%d0%be%d0%b4%d0%b0-%d0%b8-%d1%87%d1%83%d0%b2%d1%81%d1%82%d0%b2%d0%b5%d0%bd/
https://miei.ru/novosti/kak-sozdat-romanticheskoe-svidanie-kotoroe-zapomnitsya-nadolgo/
https://jrfq95.zombeek.cz
левитра и сиалис цены
https://site119450242.fo.team
https://www.bitsdujour.com/profiles/sbksPN
виагра цена купить дженерик
melbet бонус https://www.gamemelbet.ru .
https://telegra.ph/E-portal-11-17
https://snippet.host/apuaww
тадалафил Батайск
купить попперс Казань
https://telegra.ph/Filmy-sssr-01-06
https://site942594849.fo.team
https://site591049768.fo.team
форум сколько действует виагра
https://www.bitsdujour.com/profiles/mOrp3g
melbet вход с мобильного melbet вход с мобильного .
https://telegra.ph/Mystery-mtv-3229lta2-11-13
купить попперс владивосток
виагра сборники
https://snippet.host/mpwyfp
сиалис Нефтеюганск
купить виагру для женщин в ульяновске
https://7tab9h.zombeek.cz
https://telegra.ph/Malenkaya-miss-sofiya-novye-serii-11-19