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.
Sportwette Online wettanbieter ohne oasis
apostas ao vivo
Look into my site … onde apostar dinheiro (Https://it-betting.com/)
melhor grupo de planilha martingale apostas (Tyler)
live basketball wetten heute (Cortez) tipps
und tricks
tippen sportwetten
Here is my blog :: wette ohne einzahlung
box exacta bet horse race winner today (Olive) racing
united kingdom live casino, casino nsw united
states and all canadian bingo springfield mo, or
$10 deposit online casino australia
Also visit my page – 100 Random Roulette Spins
(Https://Ovm4H.Nl)
united statesn slot machine emulator, 365 online
bingo – Patsy, casino paypal deposit usa and cash
freuky casino free chips, or what online gambling is legal in united states
“mor renginin anlam?” konusu icin burada harika bilgiler var. Iste link: https://kendiyolu.com/articles/mor-rengin-anlami-ve-kullanimi/
xpokies no deposit bonus codes australia 2021, are there
casinos in toronto united states and usa slot machine categories, or best big fish casino app for android cities in united kingdom
live horse racing results today fast
my page: Https://horse-betting.Com/
Для тех, кто ищет информацию по теме “Актуальные обзоры и исследования для инвесторов”, нашел много полезного.
Ссылка ниже:
https://rub-360.ru
en apuestas rugby world cup (Maximo) que significa mas de 1.5
Ter um bom curriculo ajuda mas de nada vale se voce nao as encontra. Em nossa plataforma voce monta sua candidatura sem complicacao e logo de cara voce acompanha os empregos no Rio de Janeiro de acordo com a sua area e a sua cidade o que deixa a sua busca muito mais rapida e certeira.
all slots online nz casino tycoon 2 plot [Jeana], united kingdom online
casino accepts poli and usa casino fast withdrawal, or united kingdom poker machines online free
Salve, artigo leve e direto sobre slots novos 2026. será que alguém sabe aposta consciente? alguém usa?
como fazer aposta online
My web site … Basketball-Wetten.Com
online casino canada easy withdrawal, best free online casino Games blackjack, https://Arttrend.hu/free-spin-Without-deposit-australia/, poker games
united kingdom and grand mondial casino australia, or chukchansi gold casino
kag?t ip ormeden once yap?lmas? gerekenler hakk?ndaki yaz?y? tavsiye ederim. Suradan okuyabilirsiniz: https://evhobisi.com/articles/kagit-ip-nasil-orulur/
best online fish game Real money casino
bonuses 2021 usa, casino online uk paypal and online poker canada two plus two, or
poker sites australia 2021
$5 deposit casino usa 2021, is it legal to play online slots in australia and
australian casino chips, or the top online pokies and casinos in australia
day
My blog post – blackjack 340 (Wilfredo)
sicher wetten sportwetten
Also visit my web blog … kostenlose Basketball wett tipps für heute
Вызвать нарколога на дом следует при ухудшении самочувствия после алкоголя при длительном запое выраженном похмелье отравлении спиртным признаках абстиненции тревоге страхе бессоннице сильной слабости нарушениях поведения и невозможности самостоятельно прекратить употребление. Чем дольше человек находится в запое тем выше риск осложнений для здоровья поэтому откладывать вызов врача опасно. Подробнее – narkolog-na-dom
Polishing your resume matters but the real key is knowing where to look. On our platform you can build your profile for free and right away you can check out find out here based on your field and your city which makes your search a whole lot faster and more accurate.
Fala, pessoal, achei gold esse post sobre proteger banca. limite de depósito? vale a pena?
späte tore über unter wetten basketball
sportwetten vergleich
Also visit my homepage Tipico live wetten basketball
Basketball Wetten Tipps, Https://Ensostyle.Com/Works/Die-Rolle-Von-Coefficients-Bei-Wettprognosen/,
auf wahlausgang österreich
european online casinos real money usa players free spins, free chip no deposit usa and is
top online pokies and casinos in australia same, or new zealandn roulette guide
Look into my blog :: frenchic blackjack tester, Aleida,
poker united statesno gratis, bingo canada login and gambling legislation australia,
or real money poker apps united states
Feel free to visit my webpage; jack capital Casino
jackpot city casino online united states, united kingdom online what is the highest grossing casino in the
world – Dann
- accepts poli and online poker canada two plus two, or usa gambling license
slot machines ontario united states, top uk online casinos and best casino site
australia, or how to win roulette in casino uk
my page – craps code (Soila)
top online pokies and casinos how old do you have to be to get in casinos in vegas united states casino, usa
casinos and online poker with friends australia, or australian online casino no deposit signup bonus
captain cooks casino united kingdom review, online casinos free spins no deposit usa approved and no deposit free spins united statesn casinos, or
how to deposit cash into paypal canada
my web-site: blackjack pizza 16th st – Hildegarde -
slot machines ontario united states, casino news
uk and free spins no deposit uk low wagering, or european roulette layout usa
Here is my web page :: play earn money online
Fala — slots jackpot.