Hibernate: evict() a persistent object while storing its changes

Viewed 76591

I have a persistent hibernate object I obtained using session.save(object)

I changed it since.

I want to execute session.evict(object) to save memory, as I am done with the object.

The documentation to evict() here states that changes to the object will not be persisted. In other words - evict will cause me to lose changes I did to the object.

I could call session.flush() but that would flush all changes.

How can I persist changes made to a single persistent object before eviction?

3 Answers
Related