Only in native compilation mode the function doesn't update the entity, it creates another new entity with different id.
|
@Transactional |
|
public User update(final User u, Long idUser) { |
|
final User entity = usersRepository.findById(idUser); |
|
LOGGER.info(String.format("Encontrado usuario con dni [%s] e id [%d]", entity.getDni(), entity.getId())); |
|
entity.setFirstName(u.getFirstName()); |
|
entity.setLastName(u.getLastName()); |
|
entity.setDni(u.getDni()); |
|
entity.setEmail(u.getEmail() != null ? u.getEmail() : entity.getEmail()); |
|
entity.setGender(u.getGender() != null ? u.getGender() : entity.getGender()); |
|
entity.setPhone(u.getPhone() != null ? u.getPhone() : entity.getPhone()); |
|
usersRepository.persist(entity); |
|
return entity; |
|
} |