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://hirakbook.com/aliciagreen
https://site220562242.fo.team
https://www.udrpsearch.com/user/aliciagreen
http://zhwbn.com/bbs/space-uid-91512.html
половой акт с виагрой
http://pcbspeed.com/dis/home.php?mod=space&uid=323386
https://forum.web.ru/memberlist.php?mode=viewprofile&u=84057
https://2uq7wx.zombeek.cz
http://pcbspeed.com/dis/home.php?mod=space&uid=323243
купить сиалис 5 мг Новый Уренгой
sportwetten verluste zurückholen
Here is my web blog; wett tipps von Profis heute (Periodicooficial.Michoacan.Gob.mx)
https://www.sportchap.ru/user/AntonioBOUND/
https://www.bitsdujour.com/profiles/VIVIxX
http://ucglossa.ru/forum/profile.php?mode=viewprofile&u=667820
http://www.iawbs.com/home.php?mod=space&uid=625523
https://fdfupb.zombeek.cz
https://lessons.drawspace.com/post/388320/notebooky-lenovo-tera-cz
http://lsdsng.com/user/357338
аналог белорусский виагры
купить в гродно сиалис
http://vlexati.beget.tech/index.php?option=com_k2&view=itemlist&task=user&id=216916
https://lessons.drawspace.com/post/391440/600
дженерик Рязань
https://lessons.drawspace.com/post/390277/album
купить аванафил Брянск
https://www.hugi.is/notendur/aliciagreen/
https://zffxi8.zombeek.cz
http://witiai.cn/home.php?mod=space&uid=17504
https://www.bitsdujour.com/profiles/iStPsK
wettbüro marburg
Review my web site … buchmacher london; https://helpcenter.logintrade.pl/index.php/2025/10/07/ufc-betting-odds/,
https://paiza.io/projects/R6zK-1KiV9u9D3bckQIlOQ
https://www.sportchap.ru/user/Michaelozp/
https://www.sportchap.ru/user/Michaelkmc/
https://isqshj.zombeek.cz
https://lessons.drawspace.com/post/388184/album
https://telegra.ph/Pro-novosti-muz-tv-segodnyashnij-vypusk-11-20
http://ucglossa.ru/forum/profile.php?mode=viewprofile&u=667828
https://www.sportchap.ru/user/Michaelisy/
смазка попперс
попперс жидкость что это
http://ucglossa.ru/forum/profile.php?mode=viewprofile&u=667831
https://telegra.ph/Zvere-moe-dimitrovgrad-11-15
http://ucglossa.ru/forum/profile.php?mode=viewprofile&u=667801
попперс что это состав
https://lessons.drawspace.com/post/389089/album
https://site197239745.fo.team
https://forum.web.ru/memberlist.php?mode=viewprofile&u=83981
https://site902516650.fo.team
http://pcbspeed.com/dis/home.php?mod=space&uid=316977
https://telegra.ph/Postanovlenie-pravitelstva-553-plan-grafik-11-21