Keep your Data CORRECT: How to use Transactions in Spring Boot
In this tutorial I show you how to use transactions in Spring Boot.
💌 Know when my latest course drops and get exclusive discounts, join the Devtiro mailing list: devtiro.ck.page/498710f3be
🔗 Links
- Source Code: github.com/devtiro/spring-boo...
- Spring Transaction Management Docs: docs.spring.io/spring-framewo...
🍿 Watch Next
‣ Spring Boot for Beginners Course: bit.ly/44c1xZI
‣ Spring Data & Flyway: • Avoid a Database MELTD...
‣ Spring Boot & MongoDB: • Switch to NOSQL, move ...
🚀 *My Free Online Courses*
‣ Spring Boot for Beginners: bit.ly/44c1xZI
⌨️ *My Gear*
‣ Logitech MX Master Mouse: amzn.to/4aDGhOK
‣ Keychron K3 Keyboard: amzn.to/445FjIF
‣ Sony Alpha 6400: amzn.to/4dkl8uX
‣ Sigma 16mm F1.4 Lens: amzn.to/4d7vQEF
‣ RØDE PodMic: amzn.to/3JN4ruB
📚 Recommended Books for Devs
‣ Clean Code (A must read!) - amzn.to/3UrGA9G
‣ The Phoenix Project - amzn.to/3UsiCtZ
‣ Head First Java - amzn.to/3w3D8ZA
🤔 Who Am I
I'm Aaron Bourne, a KZreadr and Software Developer working and living in the UK. I make videos that share the skills I've built from developing software commercially for almost 15 years. I hope to make software development accessible for everyone and help to make our software better.
Timestamps
0:00 Intro & Theory
3:21 Project Dependencies
4:17 Domain Overview
5:46 Database Overview
7:12 Persistence Layer
7:48 Service Layer
10:38 Presentation Layer
11:11 Start the App
11:45 Test App Without Transactions
15:35 Enable Transactions
16:53 Test App With Transactions
18:44 Next Up
Full disclosure, some of the links in this description are affiliate links that I get a commission from.
Пікірлер: 21
Your new subscriber ❤🎉
That's very helpful, I like your videos 🔥
Thanks man. Pretty nice content!
Thanks for bringing great and simple examples to things sometimes kinda "obscure" like @Transactions!
learn a lot thanks for the explanation. I have subscribed and hit the like button
Great Explanation!!
Top video. Didn’t understand the annotation until this!
@devolajide
Жыл бұрын
Same here. I use it but I don't understand it and I have been asked in interview before.
great job. keep the good work !
better use case and good delivery. thank you for this atomic featured videos. it will change the way we knew about what we already knew. it's great please put this video in to a atomic features playlist.
helpful content, thanks
great explanation ❤👍👍
Great explanation, as in your other videos.
may be you can add introduction to the Saga pattern for distributed transactions and how to use it in Spring Boot app ?
Do i need to add Transaction Manger @Bean in the @Configuration class or is it autowired for us with Mysql / Postgres dependency or something?
@devtiro
Жыл бұрын
Thank you so much 🙏
@ajs9721
6 ай бұрын
PlatfformTransactionManager bean is auto configured. So it will work out of the box, But like everything you can override if required.
Does @validate also make the action atomic? Does it save non-validated requests?
@ajs9721
6 ай бұрын
@Valid and @Validate are JPA annotations, so that is a different use case, and will throw exception at the controller during binding, won't even go to Service layer.
All well and good using this in your service layer, but how will this work with clean architecture? The service layer would be replaced by the Domain layer and we all know the domain layer has zero dependencies on any other layer such as the outer spring layers etc. How would implement transactional behaviour using clean architecture and even things like cascade?
@mrbmro3991
5 ай бұрын
Maybe a solution is to have the controller call a dumb Service such as PersonService which contains the PersonUseCase. When the client calls PersonService.save() the save() method within the PersonService will have the @Transaction annotation and then the next line of code within PersonService.save() will be personUseCase.execute(). This way we simply delegate to the usecase where the business logic lives and at the same time it is transactional?