Transaction Management in hibernate in spring boot Interview questions | with Example | Code Decode

preview_player
Показать описание
In this video of code decode we have explained about transaction management in spring boot which is very important topic as interview perspective.

Udemy Course of Code Decode on Microservice k8s AWS CICD link:

Course Description Video :

How to implement transaction in spring / Hibernate
When you integrate Your hibernate with a spring boot project then you don’t need to use Hibernate Transaction Management, as you can leave it to the Spring declarative transaction management using @Transactional annotation.

Using @Transactional annotation.

What Is @Transactional?
We can use @Transactional to wrap a method in a database transaction.

It allows us to set
propagation,
isolation,
timeout,
read-only, and
rollback
conditions for our transaction.

How @Transactional works internally ?
Spring creates a proxy, or manipulates the class byte-code, to manage the creation, commit, and rollback of the transaction.

createTransactionIfNecessary();
try {
addEmployee();
commitTransactionAfterReturning();
} catch (exception) {
rollbackTransactionAfterThrowing();
throw exception;
}

How to use @Transational
You can use this annotation on following in the lowest to highest priority order :
interface,
superclass,
class,
interface method,
superclass method, and
method.

The EmployeeService class is annotated at the class level with the settings for a read-only transaction,
but the @Transactional annotation on the addEmployee() method in the same class takes precedence over the transactional settings defined at the class level.

Usually it's not recommended to set @Transactional on the interface; however,
it is acceptable for cases like @Repository with Spring Data. We can put the annotation on a class definition to override the transaction setting of the interface/superclass:

What is a transaction?
Transactions manage the changes that you perform in one or more systems.
These can be databases, message brokers, or any other kind of software system.
The main goal of a transaction is to provide ACID characteristics to ensure the consistency and validity of your data.

What is ACID transaction?
ACID is an acronym that stands for atomicity, consistency, isolation, and durability:

Atomicity describes an all or nothing principle. Either all operations performed within the transaction get executed or none of them. That means if you commit the transaction successfully, you can be sure that all operations got performed. It also enables you to abort a transaction and roll back all operations if an error occurs.

The consistency characteristic ensures that your transaction takes a system from one consistent state to another consistent state. That means that either all operations were rolled back and the data was set back to the state you started with or the changed data passed all consistency checks. In a relational database, that means that the modified data needs to pass all constraint checks, like foreign key or unique constraints, defined in your database.

Isolation means that changes that you perform within a transaction are not visible to any other transactions until you commit them successfully

Durability ensures that your committed changes get persisted.

Hibernate Interview Questions and Answers:

Spring Boot Interview Questions and Answers:

Subscriber and Follow Code Decode

#Transaction #springboot #codedecode
Рекомендации по теме
Комментарии
Автор

Thank you so much for making this tutorial after watching this vedio I was able to explain about transactions in details in an interview and got selected.

A BIG THANK YOU AGAIN!

amoldhanure
Автор

You were well prepared. You covered a lot in 23 minutes. A very big thank you. And yes, I need another part of Transactional series.

bablushaw
Автор

The way you are explaining with theoretically and practically is great. It is very helpful to understand the scenarios as well. Great efforts!!!
Is the 2nd Part available for this topic?

iammanishvb
Автор

One of the best videos I have seen on transaction management from an interview perspective.

theprofessor
Автор

Very well explained and yes waiting for the next set of Transactional attributes video.

vidyasagarareddyagraharam
Автор

Very well explained 👏 waiting for other distributed transactional videos also. Thanks!!

rahulshukla
Автор

Excellent explanation with theory and practical. Great job done to the code decode team..

rajesh
Автор

Thanks for the video, waiting for next video.

shrutik
Автор

Your videos are always helpful and very descriptive. Thanks :)

AmitKumar-mnri
Автор

Lot of concept covered in this short video, this hleped me to get overall picture of transaction management . Thanks a lot, appreciate your effort !!

satishkonda
Автор

One of the most important topics. Thanks team Code Decode.

sayanbiswas
Автор

Your explanation within minutes like, saving our time from understanding through different tutorials in hours or even days as well, Big thanks to you for your work, please keep posting on interview videos.

njvxdch
Автор

Very good video. A lot about Transaction Management in simple words. Please add more details about XA transactions, Named Queries and Criteria Queries…. Thanks a lot

raheshr.s
Автор

Very helpfull, was quite confused with this topic finally got cleared :)

BajrangMargonda
Автор

All of your videos are just fab.Please come up with the second part soon

EktaBhalla-ckbs
Автор

Eagerly waiting for the next part, awesome explanation, Great effort!!!

senthilrajatcs
Автор

Can't wait for more topics like this. Nice content.

hackstreet
Автор

Wow very humbled watching your videos.

Much rather be in Student Debt with you than my University where we had to learn Chemistry for Computer Science

paulsingh
Автор

Dhanshu video. Thank you so much for in depth video. Got the exact clarity related to @Transactional.

VivekSharma-vuyl
Автор

Seriously you are putting great efforts!! thanks for detailed explanation.

srjons_official