Is it possible to detach Hibernate entity, so that changes to object are not automatically saved to database?

You can detach an entity by calling Session.evict().

Other options are create a defensive copy of your entity before translation of values, or use a DTO instead of the entity in that code. I think these options are more elegant since they don’t couple conversion to JSON and persistence layer.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)