Interview Questions: Transaction Management
June 12, 2013
|Qns-1: Describe Global and Local transactions in Spring.|
Ans: Global transactions help to work with multiple transactional resources like relational database and message queue. Global transactions are managed through JTA and JNDI.
Local transactions are resource-specific like JDBC connection. Local Transactions can work with multiple transactional resources.
|Qns-2: What is the role of TransactionDefinition interface?|
Ans: a. Isolation
d. Read-only status
|Qns-3: How can we roll back a declarative transaction?|
|Ans: We can use rollback-for and no-rollback-for attributes with transactional definition.|
|Qns-4: How many types of isolation are there?|
Ans: a. ISOLATION_DEFAULT: default isolation.
b. ISOLATION_READ_COMMITTED: dirty reads are prevented, non-repeatable and phantom reads are allowed.
c. ISOLATION_READ_UNCOMMITTED : dirty reads are allowed, no-repeatable and phantom reads are allowed.
d. ISOLATION_REPEATABLE_READ: dirty reads and non-repeatable reads are prevented but phantom reads are allowed.
e. ISOLATION_SERIALIZABLE : dirty , non- repeatable reads and phantom reads are prevented.
|Qns-5: How many types of Propagation are there?|
Ans: Find the Propagation type.
a. PROPAGATION_MANDATORY : supports current transaction and throws exception if no transaction available.
b. PROPAGATION_NESTED : runs with nested transaction
c. PROPAGATION_NEVER : does not run with current transaction and throws exception if current transaction exits.
d. PROPAGATION_NOT_SUPPORTED : runs non -transactionaly and does not support current transaction.
e. PROPAGATION_REQUIRED : runs with current transaction and create one if does not exist.
f. PROPAGATION_REQUIRES_NEW : creates new transaction and suspends if exits any.
g. PROPAGATION_SUPPORTS: runs current transaction and runs non -transactionaly