What is the Callback interface in Hibernate?

Callback interface in Hibernate is mainly used for receiving notifications of different events from an object.
Whenever we call the method in the Session interface to update, persist or delete the entities; the session interface generates an applicable event based on the given executed method and passes it to the configured event listener for that type.

Example :-

  • We can use Callback to get the notification when an object is loaded into or removed from database.
  • When an object is loaded, saved, or deleted. Hibernate applications don’t need to implement these callbacks, but they’re useful for implementing certain kinds of generic functionality.
  • An event PERSIST is generated when we persist an entity using the session.persist() method.