开发者

How to force hibernate not to save and data updates on session closing?

开发者 https://www.devze.com 2023-03-15 18:47 出处:网络
For example I have entity extracted开发者_运维知识库 from hibernate session User user = session.getById(12); user.setName(\'new_name\') reject request After this code block I do not want to store upda

For example I have entity extracted开发者_运维知识库 from hibernate session User user = session.getById(12); user.setName('new_name') reject request After this code block I do not want to store updates to user and use it purely as Data Bean but also I do not want to detach it from session because I want lazy loading. For modification i want to use methods save, saveOrUpdate. Is it possible to said hibernate not to automatically update all modified fields of session objects?


FLUSHMODE.MANUAL only flushes if you specifically say to, I believe.


You can use stateless sessions. They don't do any dirty checking and corresponding auto-magic updates. Obviously, you would lose session cache (you can keep track of your objects yourself) and batched inserts/deletes/updates.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号