I need a functionality where the user can cancel the running query if she prefers, So I thought that I would serialize the hibernate session and then deserialize it back to cancel that specific query.
So I did something like:
- Serialize and set it in the DB.
- Get it back, and then call session.cancelQuery().
Below is the code I use:
ByteArrayInputStream bis = new ByteArrayInputStream(byteArray);
ObjectInput in = new ObjectInputStream(bis);
Object o = in.readObject();
Session ss = (Session) o;
But this gives me an exception at readObject():
java.io.InvalidObjectException: could not resolve session factory during session deserialization [uuid=95d6a048-677b-42f0-9b9f-7e62fd68b533, name=null]
So I wanted to know, if it is even possible to serialize and deserialize a hibernate session object.
Edit: Well I also found this, but not sure if this is correct or not!