我已经看过几篇文章,但我仍然不明白我的问题。
我有以下代码:
@Component
class API{
...
public String getTranslations(){
serviceLayer.getTranslations()
}
...
}
class ServiceLayer(){
....
public String getTranslations(){
...
for (final PulldownEntry docStructure : docStructures)
try{
structure.getTranslations(docStructure .getId())
}
catch(Exception e){
do nothing
}
}
....
}
class Structure{
....
@Transactional(propagation = Propagation.REQUIRED, noRollbackFor = Exception.class, readOnly = true)
public String getTranslations(Long structureId){
DataStructure dataStructure = dao.getObject(structureId);
if(dataStructure.hasNoData())
throw CustomException();
return dataStructure .getXML():
}
....
}
引发异常时,我得到“ UnexpectedRollbackException:事务已回滚,因为已将其标记为仅回滚的原因”,为什么?