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://snippet.host/pxgzoz
купить попперс Шахты
интернет маркетинг статьи seo-blog20.ru .
https://bcbnue.zombeek.cz
Бездепозитные бонусы в Таджикистан
купить силденафил Череповец
I’ll immediately snatch your rss as I can not to find your email subscription link or e-newsletter service. Do you’ve any? Kindly let me recognize in order that I may just subscribe. Thanks.
https://y8grh7.zombeek.cz
https://site823266367.fo.team
https://paiza.io/projects/NrYUGylZD1z0pUeLv3pY6A
pin-up lucky jet pul yechish https://www.pinup76809.help
https://telegra.ph/Prazdnik-kreshchenie-gospodne-11-08
гей сосет и нюхает попперс
Виды бонусов в казино Таджикистан
https://site723437440.fo.team
https://onespotsocial.com/yardsali78
https://pootp3.zombeek.cz
https://paiza.io/projects/tIJhOaM9-Ozbqxr1eSs5qQ
https://huqiwk.zombeek.cz
https://lessons.drawspace.com/post/1033730/comment
https://telegra.ph/Kalendar-strizhki-volos-fevral-2017-12-04
https://gwbmxb.zombeek.cz
https://ma3q6b.zombeek.cz
pinup Nukus pinup23185.help
https://dw2qfm.zombeek.cz
wettquoten bundestagswahl
Also visit my webpage :: ohne einzahlung wetten [Maxine]
https://rentry.co/h248tvpz
https://www.bitsdujour.com/profiles/WMMguk
1win plinko pe mobil 1win plinko pe mobil
buchmacher test
Also visit my website – unentschieden Basketball wetten
mostbet minimalna wpłata pl https://mostbet2003.help/
роллы недорого спб роллы недорого спб .
попперс рассказы
live-wetten
Here is my web blog :: sportwetten verluste zurückholen österreich;
https://adkangroup.com/2025/10/07/basketball-wett-tipps-Bundesliga,
https://gkrehe.zombeek.cz
https://n9hmup.zombeek.cz
https://telegra.ph/Muzej-ehrmitazh-11-14
теплоходы в санкт петербурге теплоходы в санкт петербурге .
суши мск суши мск .
https://www.bitsdujour.com/profiles/sf7Fny
how to download 1win http://1win5742.help
https://rentry.co/4szd8xr4
супер п форсе
online wettanbieter vergleich
My website :: bonus bei wettanbietern (Lino)
веб-аналитика блог seo-blog20.ru .
https://telegra.ph/Centr-zanyatosti-achinsk-03-12
https://telegra.ph/Pogoda-v-turcii-v-fevrale-2017-temperatura-vody-02-03
https://sbulxr.zombeek.cz
https://telegra.ph/Dv-hab-afisha-02-25