[英]Hibernate - update an object (entity) in DB, based on “not complete” object, without loosing values, for already filled columns
[英]how to update an object without sending the complete json of the entity
我目前正在使用“Spring Boot”。
要求是创建一个端点来更新一个实体,例如 user ,但我不想发送对象的所有“Json”,因为它有 4 个相关表并且大小增长很多。
是否可以发送选定的字段来更新对象的整个“json”?
您可以使用HTTP PATCH方法创建 API,并可以发送需要更新的字段。
当我们需要完全替换现有资源时,他们可以使用 PUT。 当我们进行部分更新时,我们可以使用 HTTP PATCH。
如果您指的是使用部分信息更新数据库,您可以使用: @DynamicUpdate(HibernateConfig.dynamicUpdate)
在仅更新更改字段的实体上。 这可能会导致性能下降,因为对 DB 的updates
使用不同的语句,这使得 DB 本身难以缓存执行计划。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.