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://www.bitsdujour.com/profiles/mF1CXi
https://telegra.ph/Wwwtrikolortv-ru-oficialnyj-sajt-12-02
https://paiza.io/projects/6XmrTIY_OgH_sadMEWMvaQ
https://telegra.ph/Fedor-mihajlovich-12-04
https://telegra.ph/Pytki-seks-12-28
Hmm it looks like your site ate my first
comment (it was super long) so I guess I’ll just sum it
up what I had written and say, I’m thoroughly enjoying your blog.
I as well am an aspiring blog blogger but I’m still new to the whole thing.
Do you have any suggestions for beginner blog writers? I’d certainly appreciate
it.
Have a look at my web-site; sportwetten bonus ohne einzahlung
neu (Oliva)
https://teletype.link/shannongrq638
sportwetten heute vorhersagen
My web-site: basketball wetten prognosen (Bernie)
купить сиалис Серпухов
https://rentry.co/6hm7sfq7
https://telegra.ph/Seks-znakomstva-volgograd-11-09
https://telegra.ph/Preparat-sialis-cena-otzyvy-01-30
Н и ж н е в а р т о в с к
попперс спб круглосуточно
у меня проблемы с эрекцией
попперсы бесплатно
sichere wetten heute
my blog … Sportwetten Paysafecard (Friderm.Com)
чат нейросеть для учебы nejroset-dlya-ucheby-7.ru .
https://site702340607.fo.team
https://gpvi7k.zombeek.cz
виагра любимый
https://rentry.co/i5xx8iqz
https://telegra.ph/Nedvizhimost-v-ulan-udeh-bez-posrednikov-11-19
buchmacher deutschland
Feel free to visit my web page; Online wettanbieter ohne Oasis
попперс эффект на женщин
https://site666906129.fo.team
https://rentry.co/6hmwofmh
где купить виагру кострома
купить попперс Владимир
https://telegra.ph/Zavodnoj-apelsin-trejler-na-russkom-02-01
https://58s3ia.zombeek.cz
попперс крем
купить попперс Ногинск
https://telegra.ph/Syntrax-11-13
где согласовать перепланировку pereplanirovka-kvartir9.ru .
werkenbij com попперс
чат нейросеть для учебы nejroset-dlya-ucheby-8.ru .
нейросеть для учебы онлайн нейросеть для учебы онлайн .
https://www.bitsdujour.com/profiles/Vo5jLL
https://telegra.ph/Russkie-boeviki-spisok-02-09
https://rentry.co/hbcx2o3h
https://www.bitsdujour.com/profiles/aNrGD2
сделать проект перепланировки квартиры в москве proekt-pereplanirovki-kvartiry22.ru .
сколько стоит оформить перепланировку квартиры skolko-stoit-uzakonit-pereplanirovku-8.ru .
https://teletype.link/aggressivewvq57
https://site25497745.fo.team
https://site211389764.fo.team
реферат через нейросеть реферат через нейросеть .