简体   繁体   中英

how to update an object without sending the complete json of the entity

I am currently using "Spring boot".

Requirement is to make an endpoint to update an entity such as a user , but I do not want to send all the "Json" of the object because it has 4 related tables and grows a lot in size.

Is it possible to send selected fields to update instead whole "json" of the object?

You could create an API with HTTP PATCH method and can send the fields which need to be updated.

When we need to replace an existing Resource entirely, they can use PUT. When we are doing a partial update, we can use HTTP PATCH.

If you referring to update the database with partial information you can use: @DynamicUpdate(HibernateConfig.dynamicUpdate) on the entity which only updates changed fields. This may cause a degradation in performance because the updates to the DB uses different statements which make it hard on the DB itself to cache the execution plans.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM