如下所示,我正在访问另一个 DAO 内部的服务层方法。(系统中的每一个DAO都是使用HibernateDAOSupport类实现的)
我想在#1 或#2(在下面的代码中注释)失败时回滚事务。但是当#2 抛出异常时,#1 不会回滚,我可以看到数据库中的条目。
@Transactional(readOnly=false, rollbackFor={DuplicateEmailException.class,DuplicateLoginIdException.class,IdentityException.class},propagation=Propagation.REQUIRES_NEW)
public void createUserProfile(UserProfile profile)
throws DuplicateEmailException, DuplicateLoginIdException,
IdentityException {
// #1 create principal using Identity Service
identityService.createPrincipal(profile.getSecurityPrincipal());
try {
// #2 save user profile using Hibernate Template
getHibernateTemplate().save(profile);
} catch (RuntimeException e) {
throw new IdentityException("UseProfile create Error", e);
}
}
这是“IdentityService”的 createPrincipal() 方法的签名。
public void createPrincipal(Principal principal) throws DuplicateEmailException,DuplicateLoginIdException,IdentityException ;
“IdentityService”中没有配置事务管理
我在这里做错了什么?