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.
sportwetten tipps kostenlos
My blog; beste e wallet wettanbieter
Онлайн казино 7k ориентировано на понятные правила и прозрачную структуру. Пользователь сразу понимает как начать игру. Это снижает количество ошибок и недоразумений. Платформа подходит для широкой аудитории: 7k casino зеркало на сегодня
Is online casino legal in Australia? – what Aussies need to know 2025
我欲为人第二季平台结合大数据AI分析,专为海外华人设计,提供高清视频和直播服务。
попперс Ноябрьск
https://site378797427.fo.team
https://qtjpqhtfcs.wordpress.com
https://site998600258.fo.team
взаимодействие виагры с
супер виагра Арзамас
виагра это было прекрасно
https://telegra.ph/Mips-2017-oficialnyj-sajt-12-04
https://rentry.co/bfbbh8e4
https://telegra.ph/Xatirla-meni-11-23
виагра для мужчин с алкоголем можно
https://paiza.io/projects/uhh5YE0leqruG47qIZ6xtg
https://telegra.ph/Ebut-szadi-12-16
купить попперс Ноябрьск
супер виагра Артём
https://telegra.ph/Poppers-EHlektrostal-01-27
https://bzily4.zombeek.cz
https://telegra.ph/Obzor-igry-majnkraft-01-06
можно ли применять сиалис
купить виагра москва
https://telegra.ph/Kak-pravilno-sdes-ili-zdes-11-11
https://telegra.ph/Spirt-alfa-01-29
https://site652223845.fo.team
https://paiza.io/projects/m4MSEyKaujT6QS2PUvQjKg
https://telegra.ph/Oprava-dlya-ochkov-zhenskaya-2016-dlya-zreniya-12-23
https://telegra.ph/Blehjd-2-smotret-onlajn-v-horoshem-kachestve-01-01
https://dwspqdxcgw.wordpress.com
https://telegra.ph/Russkoe-porno-skrytye-kamery-11-19
попперс женщин отзывы
https://telegra.ph/EHncefalopatiya-u-detej-01-26
сиалис 5 мг купить в калуге
https://www.bitsdujour.com/profiles/G6r9gC
попперс интернет магазин
https://dwspqdxcgw.wordpress.com
как правильно попперс
https://site248512745.fo.team
https://telegra.ph/Palto-osen-2016-01-07
https://xrsaugpsya.wordpress.com
https://site289838265.fo.team
виагра и простатит
https://atrioy.zombeek.cz
https://hei6yp.zombeek.cz
сиалис 5 мг Владивосток
https://jgxeqo.zombeek.cz
https://xrsaugpsya.wordpress.com
п о р н о