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://paiza.io/projects/PT5-hZo4DNu4aiqYKkzXkg
Hi there to every because I am really eager of reading this web sites post to be updated daily. It contains pleasant material. https://share.google/9QDtCxp4jpX9gczyX
https://rentry.co/qbdzcdik
https://paiza.io/projects/1j02eRalLSurDUM4NF77fw
https://rentry.co/xx2tqcdp
ночные экскурсии по санкт петербургу на теплоходе vodnyye-progulki-v-spb.ru .
суши москва суши москва .
https://rentry.co/i366xi9x
neue sportwetten seiten
Also visit my site :: wie funktioniert handicap wette (widgets.Bjy.se)
блог о рекламе и аналитике блог о рекламе и аналитике .
https://telegra.ph/Recepty-vkusnyh-salatov-na-den-rozhdeniya-prostye-i-vkusnye-s-foto-03-07
материалы по маркетингу материалы по маркетингу .
https://f1kqzc.zombeek.cz
набор для влюбленных Артём
https://telegra.ph/Posmotret-multiki-pro-mashinki-dlya-detej-besplatno-i-bez-registracii-11-10
https://telegra.ph/Viagra-cena-v-aptekah-12-30
набор суши пицца спб набор суши пицца спб .
попперс бузз
pin-up Click https://pinup76809.help/
силденафил с3 или виагра
попперс abc
какими народными средствами заменить виагру
https://telegra.ph/Poppers-mefedron-12-17
how internet partner prodvizhenie-sajtov-po-trafiku10.ru .
10 лучших онлайн казино для азербайджанских игроков
где купить жидкую виагру
mostbet как пополнить через терминал mostbet34518.help
купить дженерики
лучшие суши мск лучшие суши мск .
Хороший материал про то, как понимание региональной аудитории помогает в продвижении. Автор разбирает, чем уральский пользователь отличается от среднего по стране, и как это использовать в контенте и SEO. Есть примеры локальных запросов и рекомендации по работе с отзывами. Почитайте: https://manyppt.ru/ponimanie-osobennostej-regionalnogo-rynka-i-ego-auditorii/
https://snippet.host/sriiid
https://paiza.io/projects/EbIO75SUfHZJG2S2HTPQkw
mostbet rejestruj pl http://www.mostbet2003.help
https://snippet.host/kiencz
Онлайн беттинг и гемблинг в Таджикистан
https://sovzom.zombeek.cz
pin-up roʻyxatdan oʻtish Oʻzbekiston http://pinup23185.help/
1win password requirements http://1win5742.help
https://telegra.ph/CHem-podnyat-davlenie-v-domashnih-usloviyah-01-31
https://telegra.ph/Tatarskij-sajt-znakomstv-tatarlav-12-27
роллы доставка спб роллы доставка спб .
https://5xbylj.zombeek.cz
блог про продвижение сайтов блог про продвижение сайтов .
https://site234271379.fo.team
Yesterday while I was at work my sister stole my iphone and tested to see if it can survive a forty foot drop just so she can be a youtube sensation. My apple ipad is now broken and she has 83 views. I know this is completely off topic but I had to share it with someone https://share.google/DHxfGTlfE8OOsQ6vn
Лучшие лицензированные казино сайты Таджикистан
https://telegra.ph/Kupit-nissan-almera-bu-02-22
Keep on working great job https://share.google/qawpOB2HtCzbfoEw3
санкт петербург экскурсии по воде санкт петербург экскурсии по воде .
https://telegra.ph/SHCHenyachij-patrul-3-sezon-1-seriya-11-16