示例#1
0
 @Transactional(readOnly = false, rollbackFor = Exception.class)
 @Override
 public Role create(Role role) {
   LOGGER.debug("Role create(Role role):" + role);
   Date now = new Date();
   role.setCreatedDate(now);
   role.setUpdatedDate(now);
   LOGGER.debug("Creating a new role with information: " + role);
   return roleRepository.save(role);
 }
示例#2
0
  @Transactional(readOnly = false, rollbackFor = Exception.class)
  @Override
  public Role update(Role role) throws Exception {
    LOGGER.debug("update(Role role): " + role);
    role.setUpdatedDate(new Date());
    LOGGER.debug("Updating role with information: " + role);

    Role roleDb = roleRepository.findOne(role.getId());

    if (roleDb == null) {
      LOGGER.debug("No role found with id: " + role.getId());
      throw new Exception();
    }

    roleRepository.save(role);
    return role;
  }