@Transactional
public void schoolProcessing{
//some logic here
save(student); //student is now managed
//Calling update student
updateStudent(student) or updateStudent();
//which of the above is the correct way
}
public void updateStudent(Student student) {
//some student update logic
}
在JPA的@Transactional方法中調用方法時,我們是否應該將管理實體作爲參數傳遞?或者是因爲這被標記爲@Transactional,JPA無縫處理所有持久性,就好像所有從@Transactional調用的方法都在同一個方法中一樣?@Transactional方法調用 - 我們應該傳遞對象作爲參數嗎?
爲了澄清,上面的代碼在所有方面是否與以下相同。
@Transactional
public void schoolProcessing{
//some logic here
save(student); //student is now managed
//some student update logic
}
我認爲這是一個基本問題,但已經看到其他問題,但無法弄清楚。謝謝。