Is it possible to check the transaction of a process?

I would like to be able to check whether each unit of work is executed in its own transaction or as part of one global transaction.

I have a method (defined using spring and hibernate) that looks like:

private void updateUser() {
    updateSomething();
    updateSomethingElse();
}

It is called from two places, a website when a user logs in, and a batch job that runs daily. For the web server context, it will start with the transaction created by the web server. For a batch job, it must have one transaction for each user, so if something fails during this method, the transaction is rolled back. So, we have two methods:

@Transactional(propagation=Propagation.REQUIRES_NEW)
public void updateUserCreateNewTransaction() {
    updateUser();
}

@Transactional(propagation=Propagation.REQUIRED)
public void updateUserWithExistingTransaction() {
    updateUser();
}

updateUserCreateNewTransaction () is called from a batch job and updateUserWithExistingTransaction () is called from a web server context.

. , () , , . , .

, :

  • , .

  • - , , updateSomethingElse() , updateSomething() .

  • .

1 - , , hibernate ?. 2 , . 3 , .

, - , , ?

+5
2

unit test, HSQLDB EasyMock ( - ).

updateSomething() HSQL, -, updateSomethingElse() RuntimeException . , HSQLDB, , updateSomething() .

HSQLDB - , , , , .

+2
0

All Articles