java - Why are life-cycle listeners in Hibernate Serializable? -


After

Apply the hibernate interface that you provide to the event listeners, for example: org.hibernate. Event.PostInsertEventListener; All are serializable

However, it does not seem to explain anywhere why your audience needs to be sorted. We were injecting the DAO with the database connection for a while, and it has not yet failed, although I am worried that there may be a case where hibernate passes the listener on a serialized link, and thus Database lost connection

So the question is: Why should the hibernate event listeners have serialjob?

Although I'm not sure I understand your question properly, I do not know that serial What could be the problem with the event listener?

An event listener should be implemented as if it was a singleton and they do not want to keep any state in the frequency variable.

So serializing should not be a problem.

A DAO can be serialized (for obvious reasons).

If you really have an event listener with reference to a DAO, then mark the DAO variable as a transient. When you use DAO to clear the check and if the nose receives epprootio dio from DAOFactory.


Comments