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://bpx0iw.zombeek.cz
купить в москве сиалис тадалафил
https://teletype.link/fantasyxvo67
https://telegra.ph/Skachat-besplatno-pesni-novinki-2016-populyarnye-russkie-veselye-11-28
https://site79670935.fo.team
купить сиалис софт Чита
https://telegra.ph/Kak-vliyaet-viagra-na-zrenie-12-21
попперсы уфа
https://telegra.ph/Kreatura-ehto-12-01
перепланировка помещения sites.google.com/view/dokument-dlya-pereplan/главная-страница .
кухни под заказ kuhni-spb-41.ru .
https://site724842310.fo.team
https://telegra.ph/Uplata-transportnogo-naloga-yuridicheskimi-licami-v-2016-godu-11-15
купить попперс Балашиха
заказать кухню каталог заказать кухню каталог .
https://telegra.ph/Viagra-Krasnogorsk-12-10
попперс где купить спб
попперс 24 доставка спб
https://wfcd3p.zombeek.cz
действие виагры купить виагру в аптеке
заказать кухню в интернете zakazat-kuhnyu-1.ru .
купить попперс в краснодаре 23 ру
в и а г р у
печать полиграфии в Москве https://teletype.in/writes/6s1s5pxlws9 .
виагра живика
https://telegra.ph/Sofya-temnikova-instagram-02-15
https://www.bitsdujour.com/profiles/fWWZkO
1win aviator 2026 http://1win5767.help/
купить виагра софт Хабаровск
https://c1fpam.zombeek.cz
https://telegra.ph/Poppers-chto-ehto-takoe-prostymi-slovami-12-29
попперс Великий Новгород
липецк попперс купить
https://paiza.io/projects/W2ovnVpFr0aCI48p-WGiqw
https://site750003983.fo.team
apuestas playoff caballos hipodromo
купить пробник виагры
https://teletype.link/widthyxr23
https://telegra.ph/Srochnyj-vklad-11-26
сиалис Октябрьский
https://telegra.ph/Niva-shevrole-kupit-u-dilera-11-17
https://paiza.io/projects/Wqx34XQdVASiT4fbZB2wGg
https://site2677967.fo.team
попперс для девушки
https://snippet.host/raocce
https://site290398861.fo.team
попперс Златоуст
https://telegra.ph/Smeshno-foto-01-30
https://qnh3ag.zombeek.cz
внедрение erp цена 1с внедрение erp цена 1с .