Lazy loading after de-serialising hibernate entities

I have been working with hibernate ORM for some time now and I have come across a problem. I want to serialise LAZY LOADED hibernate entities, store them( redis ), say and de-serialise them when I need them. But the problem is when my application goes down and gets back up, the session factory for my database created by hibernate gets recreated and session factory UUID regenerated. “The session Factory Registry” now has no mapping of the old session factory and the lazy loading process fails and an Exception is thrown. This problem would never occur when my Application were to “never go down”. Is there a solution for lazy loading de-serialised entities when the application goes down and comes online again? I tried to give a session factory name so that the entities are lazy loaded by referencing the factory by name, didn’t work. does anybody know the solution? alternate ones are also fine.

Serializing a LAZY entity is not a very good idea. You should serialize only entities that are fully loaded.

I don’t think you can fix this without changing Hibernatte code,