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.
live odds danmark italien bundesliga
https://xn--zlv426e.xn--cksr0a.tw/home.php?mod=space&uid=141
https://doc.dcrich.net/s/rTzlnIByJx
https://hedgedoc.sa6anw.se/s/O7s4SQoZPc
https://docs.meriales.ca/s/CRW6RmgZ-W
https://gratisafhalen.be/author/frederickuhn5757/
Get access to cricket apps with prediction leagues.
https://telegra.ph/CHerez-vershinu-v-romba-avsd-provedena-pryamaya-vm-perpendikulyarna-03-14
vedonlyönti aloittelijalle
Take a look at my web site … paavin valinta kertoimet (Rodney)
888 poker promotion code united states, united statesn roulette betting strategy and
bet365 united statesn roulette guide uk, or best online
pokies free spins no deposit canada
My blog post: burswood crown casino bars (Charissa)
https://telegra.ph/Smotret-titanik-v-horoshem-kachestve-hd-720-01-02
https://amlsing.com/home.php?mod=space&uid=666572&do=profile&from=space
https://site791603950.fo.team
poker united statesno gratis, usa online casino no deposit and pokie machine
laws united states, or online casinos accepting usa
Here is my web page; when can you split your cards in blackjack (Russ)
https://vcook.jp/users/91664
https://hedgedoc.faimaison.net/s/Nw41yzu7x6
https://hedgedoc.envs.net/s/n8kOwq5bR
descargar juegos de casinos sin deposito permitido en españa para celular
https://www.instructorsnearme.com/author/skiingrfg3363/
casas apuestas al dia sin licencia
https://pads.zapf.in/s/f53M7YUs3v
casino 25 euro einzahlung eps
Here is my website; Zar casinos ohne anzahlung Bonus
https://greyhoundgreetings.com/author/tourswih210/
zahraniční online casina s nízkýM vkladem 2026
casino t-mobile platba
https://snippet.host/wcibfn
https://bbs.zp68.com/space-uid-35936.html
https://www.instructorsnearme.com/author/voluntaryoxg36/
gambling taxes australia, new zealand poker players and new gambling legislation united states,
or awesome online casino new zealand
my page: make money on casinos [Jefferson]
https://md.jakefarrell.ie/s/jcmLygeoft
https://snippet.host/ubneqv
https://telegra.ph/Mesto-dislokacii-11-11
https://demo.wowonder.com/1778038101874518_550541
megaways Casino Slots Sticky Wilds app echtgeld
https://rentry.co/2oy3weut
https://paper.wf/orlandovts4221/dlia-prosmotra-bez-reklamy-oformite-podpisku-serialy-stali-neot-emlemoi-chast-iu
https://www.roton.com/forums/users/1hev1khmbd/
https://pad.funkwhale.audio/s/kb3BlZGxV
https://docs.klg21.de/s/2UJLja2S8
https://pads.zapf.in/s/M5Pp1_nebl
https://pads.zapf.in/s/M5Pp1_nebl
http://jobboard.piasd.org/author/indicatorsehr41/
https://diapo.cemea.org/s/JhUCW1XAQ
https://forum.iccfish.com/space-uid-50680.html
https://site328606643.fo.team
попперс в ижевске
https://roadcosmos.com/author/breedayh7381/
online casino ohne autoplay sperre kreditkarte (Earle) casino ab
30 euro sofortüberweisung
https://pad.riot-os.org/s/AfR7Z3RScl
https://espritgames.com/members/51003482/
https://amlsing.com/home.php?mod=space&uid=839450&do=profile&from=space