I\'m trying to get the old entity in a @HandleBeforeSave event.
@Component
@RepositoryEventHandler(Customer.class)
public class CustomerEventHan
Just another solution using model:
public class Customer {
@JsonIgnore
private String name;
@JsonIgnore
@Transient
private String newName;
public void setName(String name){
this.name = name;
}
@JsonProperty("name")
public void setNewName(String newName){
this.newName = newName;
}
@JsonProperty
public void getName(String name){
return name;
}
public void getNewName(String newName){
return newName;
}
}
Alternative to consider. Might be reasonable if you need some special handling for this use-case then treat it separately. Do not allow direct property writing on the object. Create a separate endpoint with a custom controller to rename customer.
Example request:
POST /customers/{id}/identity
{
"name": "New name"
}