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://telegra.ph/Http-intmail-11185-cn-zdxt-yjcx-11-21
https://site271571185.fo.team
https://5zmksu.zombeek.cz
1win Кыргызстан кирүү http://www.1win20819.help
бездепозитные бонусы в казино за регистрацию в Грузии
https://rentry.co/ck5y7g6g
https://www.bitsdujour.com/profiles/SJE5ZS
https://telegra.ph/Gusevskij-politehnicheskij-tehnikum-oficialnyj-sajt-03-07
https://kukeaq.zombeek.cz
https://site474151520.fo.team
попперс котельники
виагра новое онлайн
https://rentry.co/ub5f43i5
запрещены ли попперсы в россии
купить попперс Магнитогорск
https://rentry.co/bu94g7zo
купить попперс Златоуст
https://telegra.ph/Pogoda-astrahan-na-mesyac-01-15
https://qsllvw.zombeek.cz
https://telegra.ph/EHpoha-vikingov-02-25
https://telegra.ph/Mbk-centr-bankovskih-analitikov-12-13
https://4dsz9f.zombeek.cz
Connect the millions delightful colossal on fan maxxwins – the #1 legitimate coins casino app in America. Respite c start your 1000 WITH IT AGAIN bonus and turn every make up hand and somersault into bona fide coin of the realm rewards. Fast payouts gigantic jackpots and day in action – download FanDuel Casino any longer and start playing like a pro today
https://si9jmu.zombeek.cz
https://snippet.host/fpgvvn
нарколог на дом стоимость ростов-на-дону нарколог на дом стоимость ростов-на-дону .
купить женское кольцо https://kolca-pomolvka-msk.ru
сиалис в аптека ру
Curious about the weather Podgorica vremenska prognoza today. Detailed 7- and 10-day forecasts including temperature wind precipitation humidity and pressure. Up-to-date information on the climate and weather conditions in Podgorica for travel and leisure.
https://telegra.ph/Top-40-evropa-plyus-2016-02-16
https://telegra.ph/Ragda-hanieva-11-18
https://snippet.host/vfxqcu
https://lwktct.zombeek.cz
https://www.bitsdujour.com/profiles/Yh6w66
https://rentry.co/b543trks
Hacksaw Gaming – это провайдер который многие выбирают за драйв нестандартные механики и мощные бонусные режимы. Но из-за большого количества тайтлов легко пропустить реально стоящие игры или не понять где какая волатильность и “характер” слота. Мы собрали это в Telegram-канале: обзоры рекомендации новинки и короткие разборы слотов Hacksaw. Ссылка: https://t.me/s/hacksaw_slots
https://p1etor.zombeek.cz
https://telegra.ph/Skazochnoe-puteshestvie-mistera-bilbo-begginsa-hobbita-film-1985-11-16
сиалис Рубцовск
купить попперс Красногорск
pinup qanday roʻyxatdan oʻtish pinup qanday roʻyxatdan oʻtish
https://snippet.host/zwmtkd
https://telegra.ph/1plus1-ua-11-19
купить супер левитра Обнинск
купить попперс Альметьевск
mostbet oglinda functionala http://mostbet63218.help/
mostbet lucky jet 2026 https://mostbet20748.help/
https://site389300843.fo.team
попперс и алкоголь совместимость
mostbet бонус 2026 http://mostbet20748.help