I was quite surprised to find out that Hibernate automatically saves dirty objects at the end of transaction, without explicit calls to something like
dao.save(object)
I have in mind the situation described by this thread
My question is: is there a way to disable this behaviour? At first glance this automatic saving seems rather dangerous because you need to know which objects are connected to the session and which not and it seems pretty easy to save something by mistake. Can you tell me what the benefits of this automatic-saving approach are? I hardly see any. I'd like to always explicitly call dao.save(object) to update anything.
I heard of one possible workaround to this, which is using an entityInterceptor on your sessionFactory. This custom entityInterceptor would override the findDirty method to never find anything dirty, but in such case I suppose dao.save won't also work. Any ideas?