jeudi 2 avril 2015

Synchronized Transactional method in Spring

We have following method in our code which has Transactional annotation and is synchronized.



@Transactional(propagation=Propagation.REQUIRED, rollbackFor=Exception.class)
public synchronized void addValueToDB(String value, int parent) {
int nextId = getNextIDUsingSequence();
insertIntoDB(nextId, value);
updateLeft(parent);
updateRight(parent);
}


Now as Transactional annotation commits in database after method completion so synchronization on this method seems useless to me? Does spring provides any solution to this or should I synchronize the block from where this method is getting called?


Aucun commentaire:

Enregistrer un commentaire