我需要你帮助解决一个问题.我在DAO类中有这样的方法来保存角色:
@Repository(value="jdbcRoleDAO")
@Transactional(propagation=Propagation.SUPPORTS, readOnly=true, rollbackFor=Exception.class)
public class JdbcRoleDAO implements RoleDAO {
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private DBLogger<Role> dbLogger;
/**
* @throws DublicateEntryException if object with specified unique for application field already
* exists in DB.
*/
@CacheEvict(value = "roles", allEntries = true)
@Transactional(propagation=Propagation.REQUIRED, readOnly=false, rollbackFor=Exception.class)
@Override
public Role save(final Role role) {
if (this.getRoleByName(role.getName()) != null) {
throw new DublicateEntryException("Record with specified role name already exists in application.");
}
KeyHolder keyHolder = new GeneratedKeyHolder();
jdbcTemplate.update(new PreparedStatementCreator() {
@Override
public …Run Code Online (Sandbox Code Playgroud)