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

前端 未结 5 1229
野性不改
野性不改 2020-11-30 00:12

I have Hibernate entity that I have to convert to JSON, and I have to translate some values in entity, but when I translate values, these values are instantly saved to datab

5条回答
  •  遥遥无期
    2020-11-30 01:03

    Close the Session. That will detach your entity for you, and no modifications will be flushed. If that's not possible, look into disabling autoFlush...but that's a whole other can of worms. The easiest is to close the Session and be done with it!

提交回复
热议问题