spring transaction management interview questions

Top Frequently Asked Spring Transaction Management Interview Questions

What is transaction ?

It is a sequence of action that are considered as a single unit of work.These actions should either complete entirely or should not at all.For example money transfer from one account to another , in which one account is debited and other is credited but all actions is considered under single transaction.

Which properties a transaction should follow ?

A transaction should follow ACID properties.

  • Atomicity
  • Consistency
  • Isolation
  • Durability

What is Atomicity ?

It means all actions in a single transaction should complete successfully or transaction itself should be considered unsuccessful.For example if money is transferred from one account to another then either money should debited from one account and credited into another successfully or no credit and debit should happen in both accounts.

What is Consistency ?

When a transaction happens then system moves from one state to another.Consistency ensures that both state is valid and are according to transaction rule if after state fails then system is moved again to its early state that was before transaction.

What does it mean by Isolation ?

Every transaction should be isolated to other transaction, it means a transaction should not impact on other transaction.

Explain Durability ?

Once a transaction is complete then result should move into permanent resource. even after system failure result should not be erased.

What is the Difference between Local and Global transaction ?

Local is specific to single transactional resource like JDBC while Global involves multiple transactional resources like in distributed resources.

Local is easy to implement because generally Local transaction is useful in centralized computing environment where application components and resources are located at single site and data manager runs in single machine.

Global transactional management happens in a distributed computing environment where resource are distributed at multiple places and we need to maintain at both local and global levels.

What are the types that spring transactional management support ?

  • Programmatic
  • Declarative

What is Programmatic Transactional Management ?

In Programmatic Transactional Management using program we handle transaction.It provides flexibility but its difficult to maintain.

What is Programmatic Declarative Management ?

In Declarative Transactional Management using Spring annotation or XML configuration we handle transaction.It is less flexible compared to Programmatic Transactional Management but its easy to maintain.

What are the possible values for isolation level ?

  • TransactionDefinition.ISOLATION_DEFAULT
  • TransactionDefinition.ISOLATION_READ_COMMITTED
  • TransactionDefinition.ISOLATION_READ_UNCOMMITTED
  • TransactionDefinition.ISOLATION_REPEATABLE_READ
  • TransactionDefinition.ISOLATION_SERIALIZABLE

What are the possible values for propagation type ?

  • TransactionDefinition.PROPAGATION_MANDATORY
  • TransactionDefinition.PROPAGATION_NEVER
  • TransactionDefinition.PROPAGATION_NESTED
  • TransactionDefinition.PROPAGATION_NOT_SUPPORTED
  • TransactionDefinition.PROPAGATION_REQUIRED
  • TransactionDefinition.PROPAGATION_REQUIRES_NEW
  • TransactionDefinition.TIMEOUT_DEFAULT
  • TransactionDefinition.PROPAGATION_SUPPORTS


A method is annotated with PROPAGATION_REQUIRED then it creates new transaction if there is no exist otherwise uses the existing transaction, In this PROPAGATION_REQUIRED scenario if a method calls another method that also uses PROPAGATION_REQUIRED then during exception in inner method complete transaction is rolled back.

In PROPAGATION_REQUIRES_NEW if a method is annotated with this propagation then every time new transaction will be created and if exception occurs in inner method then only inner method transaction will be rolled back.

Visit Others Links

Interview Questions Top Elasticsearch Interview Question
Top Kubernetes Interview Question
Top HTTP Interview Question
Top PouchDB Interview Question
Top Pivotal Cloud Foundry (pcf) Interview Question
Top Apache Camel Interview Question
Top Docker Interview Question
Top Gradle Interview Question
Top Generics Interview Questions In Java
Java 9 Interview Questions
Top Maven Interview Question
Top RabbitMQ Interview Question
Top Spring Batch Interview Question
Top Spring Boot Interview Question
Top Tika Interview Question
Top Kotlin Interview Question
Top OpenShift Interview Question
Top Polymer Interview Question
Top WebGL Interview Question
Top Continuous Integration Interview Question
Top Spring Cloud Interview Question
Top JOGL Interview Question
Top JFreeChart Interview Question
Java MultiThreading Interview Question
Top Spring ROO Interview Question
Top Seaborn Interview Question
Top TestRail Interview Question
Top LolCode Interview Question
Top Spring Transaction Management Interview Question
Top DynamoDB Interview Question
Top PySpark Interview Question
Top SaltStack Interview Question
Top Spring AOP Interview Question
© 2019 PreparationForInterview.com