Transactions Flashcards

1
Q

What are the transaction management types that can be defined for an EJB?

A

Container

Bean

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you specify a transaction management type using annotations?

A

@TransactionManagement is a class level annotation that accepts one argument of either:
TransactionManagementType.BEAN
TransactionManagementType.CONTAINER

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the default transaction management type?

A

TransactionManagementType.CONTAINER

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the transaction types that can be attached to a class or a method?

A

MANDATORY, REQUIRED, REQUIRES_NEW, SUPPORTS, NOT_SUPPORTED, NEVER

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How are transaction types specified?

A

Using @TransactionAttribute either at the class level and or method level.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the default transaction type?

A

REQUIRED

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Explain the MANDATORY transaction type.

A

MANDATORY: If this attribute is specified for a method, a transaction is expected to have already been started and be active when the method is called. If no transaction is active, an exception is thrown. This attribute is seldom used, but can be a development tool to catch transaction demarcation errors when it is expected that a transaction should already have been started.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Explain the REQUIRED transaction type.

A

REQUIRED: This attribute is the most common case in which a method is expected to be in a transaction. The container provides a guarantee that a transaction is active for the method. If one is already active, it is used; if one does not exist, a new transaction is created for the method execution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Explain the REQUIRES_NEW transaction type.

A

REQUIRES_NEW: This attribute is used when the method always needs to be in its own transaction; that is, the method should be committed or rolled back independently of methods further up the call stack. It should be used with caution because it can lead to excessive transaction overhead.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Explain the SUPPORTS transaction type.

A

SUPPORTS: Methods marked with supports are not dependent on a transaction, but will tolerate running inside one if it exists. This is an indicator that no transactional resources are accessed in the method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Explain the NOT_SUPPORTED transaction type.

A

NOT_SUPPORTED: A method marked to not support transactions will cause the container to suspend the current transaction if one is active when the method is called. It implies that the method does not perform transactional operations, but might fail in other ways that could undesirably affect the outcome of a transaction. This is not a commonly used attribute.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Explain the NEVER transaction type.

A

NEVER: A method marked to never support transactions will cause the container to throw an exception if a transaction is active when the method is called. This attribute is very seldom used, but can be a development tool to catch transaction demarcation errors when it is expected that transactions should already have been completed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly