When the transaction will be committed?

I need some clarification regarding Spring transation.

In ClassA I am creating a declaritive transaction. From ClassA I am calling method1() of ClassB.

ClassB is having @Transactional(propagation = Propagation.REQUIRED) annotation in classs level.

In method1() I am doing a save operation.

My question is, when that data will be committed ? Will it be committed while control will come out from

method1()? or in ClassA where we are committing the transaction manually ?.

Code:

ClassA

class ClassA {

void myMethod() {

TransactionStatus status = null;

DefaultTransactionDefinition def =

new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRES_NEW);

def.setTimeout(contentFileProcessingConfigBean.getFileCopyTransactionTimeout());

status = transactionManager.getTransaction(def);

b.method1();

if (status != null) {

transactionManager.commit(status);

}

}

}

ClassB

@Transactional(propagation = Propagation.REQUIRED)

class ClassB {

void...

Read More »

By: StackOverFlow - Wednesday, 14 November

Related Posts