0
all right? I am using java and spring-framework in a restful project, so I created the following class:
Categoria
(id, descrição, dtCadastro, dtAlteração)
In class I am using the annotations @PrePersist
and @PreUpdate
for date fields, so they are automatically updated when I persist with a new object or when I update an existing object.
In the application I manipulate objects of this type using a DTO (Categoriadto) with the following attributes:
(id, descrição)
The date fields were omitted because they are fields used for auditing the persisted data and are not manipulated by the client.
The problem is that when I use Beanutils.copyProperties in an update end point it ends up generating null in the date fields, because DTO does not have these fields.
Beanutils.copyProperties also has a signature that lets you ignore a field, I’m using it to ignore the id in the update process.
BeanUtils.copyProperties(dto, dtoAtualizado, "id");
Is there any class that has a similar method (copy values from fields to another object) but that allows ignoring more than one field?
Thanks for the returns.