SDR中的投影非常适合控制json输出。但是输入,REST调用中的参数呢?
[当我实现自己的控制器时,我可以通过任一方法来为输入(创建/更新)定制一个'投影'
这两种方法都不适用于SDR,因为您没有编写控制器。这是怎么做的?
反映评论部分讨论的问题:
向实体添加@Postload
方法:
@PostLoad
public void postLoad() {
... store the values of the un-updateable fields into transient fields with @JsonIgnore
}
@JsonIgnore
@Transient
private String originalValue1;
@JsonIgnore
@Transient
private String originalValue2;
创建@HandleBeforeSave
事件处理程序。在更新过程中调用它,但在创建过程中不调用。
将存储的值复制到此处理程序中的原始字段。